Search
When search is on
By default search turns on by itself when a select has more than 8 options, and always for multiple, remote and create. Force it with data-fs-search:
| Value | Result |
|---|---|
| (not set) | Automatic, as above |
true | On, in the default position for the variant |
inline | On, typing happens inside the control |
dropdown | On, a search box sits at the top of the list |
false | Off |
The default position is inline for the field variant and dropdown for pill and ghost.
The threshold is the searchThreshold option. Change it for every select with FlowSelect.defaults.searchThreshold = 12.
Options added later
The automatic choice is made when the select starts. If your script adds the options afterwards, set data-fs-search explicitly.
Inline search
You type directly in the control, like a combobox. While the list is open the current value fades; as soon as you type it is replaced by your text. Press Esc and the value comes back.
<select name="country" data-flow-select data-fs-search="inline">...</select>Search in the list
A search box appears at the top of the list, like a command menu. This is the default for pill and ghost.
<select data-flow-select data-fs-search="dropdown" data-fs-search-placeholder="Search countries...">...</select>On touch screens the search box is not focused when the list opens, so the on-screen keyboard only appears when you tap the box.
How matching works
- Case and accents are ignored:
cotefinds "Côte d'Ivoire",mexicofinds "México". - Several words must all match, in any order:
new yorkfinds "America / New York". - Options whose label starts with your text come first (unless the list has groups, which keep their order).
- The label,
data-meta,data-descriptionanddata-keywordsare searched. Use keywords for synonyms:
<option value="de" data-keywords="deutschland allemagne">Germany</option>Without search
With search off, typing letters on the closed control selects the next matching option, exactly like a native select. Typing the same letter again cycles through matches.
Long lists
Lists render 100 rows at a time and add more as you scroll, so even 10,000 options open instantly.