Combobox
A text input whose results open under it: accent-insensitive ranked matching with bold matches, recent picks, server results with a spinner, a create row, keys, and results that stay above the keyboard.
npx @swipeui/cli add comboboxWhen to use it
- Picking one item from hundreds, such as a country, a city or a time zone, where typing is fastest.
- Assigning a person or project by searching their name.
- Any single choice where people already know what they're looking for.
When not to use it
- Short lists people scan rather than search. Use Dropdown or Radio group.
- Several choices. Use Multi-select.
- Free text with suggestions you don't need to pick from. Use Text field or Search field.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add combobox- Adds
components/swipeui/ui/combobox.tsx,components/swipeui/ui/use-combobox.tsand 21 shared helpers. - Installs react-native-reanimated, clsx, tailwind-merge, react-native-worklets, uniwind, expo-haptics, class-variance-authority, react-native-svg, react-native-gesture-handler, react-native-safe-area-context, @expo/ui, @gorhom/bottom-sheet, expo-blur. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Combobox } from '@/components/swipeui/ui/combobox';
<Combobox
label="City"
options={[
{ value: 'sao', label: 'São Paulo' },
{ value: 'nyc', label: 'New York', keywords: ['NYC'] },
]}
/>;The results open in a popover, so put OverlayProvider near the app root.
Examples
Results from your server: turn local filtering off, pass the results and show the spinner while they load. onQueryChange gets the query once typing rests:
<Combobox label="Book" options={results} filter={false} loading={loading} onQueryChange={search} />Offer to create what isn't there:
<Combobox label="Tag" options={tags} onCreate={(name) => addTag(name)} />API reference
ComboboxProps
| Prop | Type | Default | Description |
|---|---|---|---|
label | | — | The visible and spoken name. An empty string hides it visually. |
options | | — | The options, in order. Group them with |
groups? | | — | Group headings, in order. |
value? | | — | The chosen value (controlled); |
defaultValue? | | | The value it starts with (uncontrolled). |
onValueChange? | | — | Reports a pick, or |
query? | | | The query that filters the results (controlled, for server search); typing still reports through |
onQueryChange? | | — | Reports the query once typing settles for |
debounce? | | | How long the query rests before |
placeholder? | | | Shown in the empty input. |
filter? | | | How options are matched: accent-folded, ranked, over labels and keywords; or your own; or |
loading? | | | Results are on their way: a spinner in the field and "Searching…" in the list. |
onCreate? | | — | Offers a "Create “query”" row when nothing matches exactly, and calls this when it's picked. |
recent? | | — | Recent picks shown first on an empty query. Leave it out to remember this session's picks. |
rememberRecent? | | | How many picks to remember when |
presentation? | | |
|
highlightMatches? | | | Bold the letters that match. |
openOnFocus? | | | Show results as soon as the input is focused. |
clearable? | | | A clear button in the input while it has text; clearing also clears the value. |
maxListHeight? | | | The tallest the results may be, in points; they also stop above the keyboard. |
helper? | | — | Supporting text under the field. |
error? | | — | Validation message. |
success? | | — | Confirmation text; replaces the helper. |
status? | | | Validation state shown on the field ( |
required? | | | Marks the field required. |
requiredIndicator? | | | How a required field is marked. |
optionalIndicator? | | | Show "Optional" after the label. |
disabled? | | | No typing or picking. |
disabledStyle? | | |
|
appearance? | | | The field's surface. |
size? | | |
|
shape? | | |
|
labelPlacement? | | | Where the label sits. |
focusRing? | | | The ring and halo while focused. |
leadingIcon? | | — | A leading icon in the field (the chosen option's icon replaces it). |
messages? | | | Built-in strings, for translation. |
haptics? | | | Haptics: a switch, or per part ( |
motion? | | | Field, list and highlight motion. |
className? | | — | Classes on the field. |
style? | | — | Field style. |
testID? | | — | The input's identifier. The list appends |
Options are SelectionOptions from selection-core: value, label, description, detail, icon, keywords, group, disabled and disabledReason.
Composition and behavior
- Focus the field and the results open under it at its width: recent picks first (remembered for the session unless you pass
recent), then everything. - Typing narrows them: accents fold ("sao" finds São Paulo), keywords and aliases match ("NYC"), prefix matches rank first, and the matched letters are bold.
- Tap a result to choose it. Focus stays in the input the whole time; presses on rows don't take it away.
- On the web: Down and Up move through the results, Enter picks, Escape throws the typed query away and then closes, and leaving the field closes them.
- ★ The results stop above the keyboard and open upwards when there's more room there. ★ Android's back button clears the query, then closes the results.
- The result count, or "No matches", is announced once typing rests. Clearing the text clears the value.
presentation="sheet"keeps the 1.x field that opens a searchable sheet.
Combobox settings
| Prop | Does | Default |
|---|---|---|
| filter | Accent-folded ranked matching, your own, or false | matchOptions |
| onQueryChange / debounce | The query once typing rests (ms) | none, 200 |
| loading | A spinner and "Searching…" | false |
| onCreate | A "Create “query”" row | none |
| recent / rememberRecent | Recent picks first; how many to remember | session, 3 |
| highlightMatches | Bold matched letters | true |
| openOnFocus | Open the results on focus | true |
| clearable | A clear button while there's text | true |
| maxListHeight | Tallest results (pt), within the room above the keyboard | 320 |
| presentation | popover (inline) or the 1.x sheet | popover |
| appearance / size / shape | Field look | filled, md, preset |
| helper / error / success | Messages under the field | none |
| required / disabled | Required mark; no typing | false |
| haptics | All, or { select, clear } | select |
| messages | Placeholder, "Searching…", create, "Recent", results | English |
Behavior and gestures
- Focus the field and the results open under it (`openOnFocus`): recent picks first, then everything.
- Type to narrow them: accents fold ("sao" finds São Paulo), keywords and aliases match ("NYC"), and prefix matches rank first. Matched letters are bold (`highlightMatches`).
- Tap a result to choose it: the field shows its label and the results close, with a selection tick. Picks are remembered for this session (`rememberRecent`) unless you pass `recent`.
- On the web, Down and Up move through the results, Enter picks, Escape throws the typed query away and then closes, and Tab or a click elsewhere closes.
- With `onCreate`, a "Create “query”" row appears when nothing matches exactly.
- For server search, pass `filter={false}` and the results as `options`; `onQueryChange` gets the query once typing rests (`debounce`), and `loading` shows a spinner and "Searching…".
- ★ The results stop above the keyboard and open upwards when there's more room there. ★ Android's back button clears the query, then closes the results.
- Clearing the text clears the value. `presentation="sheet"` keeps the 1.x field that opens a searchable sheet.
Accessibility
- The input has the combobox role with expanded state; results are radios with checked state, and a disabled one speaks its reason.
- The result count (or "No matches") is announced once typing rests; a pick is announced with its label.
- Focus stays in the input while results are open: presses on rows don't take it away.
Motion
- Uses the
overlay,select,toggleandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The results open on the overlay role; the highlight glides to the active row on the select role and the check draws on the toggle role.
- Reduce Motion: the results fade and the highlight jumps.
Performance
- Filtering is local, accent-folded and ranked; nothing is sent anywhere unless your `onQueryChange` does. The popover holds one plain list, so keep local option lists to a few hundred.
Notes for AI
- Options are `SelectionOption`s (label, description, detail, icon, keywords, group, disabledReason). `value` is the chosen option's value or null.
- Popovers need `OverlayProvider` at the app root; the 1.x sheet needs `SheetProvider`.
- Server search: `filter={false}`, `options={results}`, `loading`, `onQueryChange`.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.