SwipeUI

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 combobox
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When 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.ts and 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 install so versions match your SDK.

Usage

app/assign.tsx
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

PropTypeDefaultDescription
labelstring—

The visible and spoken name. An empty string hides it visually.

optionsreadonly ComboboxOption<T>[]—

The options, in order. Group them with group and groups.

groups?readonly SelectionGroup[]—

Group headings, in order.

value?T | null—

The chosen value (controlled); null means nothing is chosen.

defaultValue?T | nullnull

The value it starts with (uncontrolled).

onValueChange?((value: T | null) => void)—

Reports a pick, or null after clearing.

query?stringwhat's typed

The query that filters the results (controlled, for server search); typing still reports through onQueryChange.

onQueryChange?((query: string) => void)—

Reports the query once typing settles for debounce milliseconds (for server search).

debounce?number200

How long the query rests before onQueryChange and the results announcement, in milliseconds (content timing).

placeholder?string'Search'

Shown in the empty input.

filter?ComboboxFilter<T>matchOptions

How options are matched: accent-folded, ranked, over labels and keywords; or your own; or false to show options as given (server results).

loading?booleanfalse

Results are on their way: a spinner in the field and "Searching…" in the list.

onCreate?((query: string) => void)—

Offers a "Create “query”" row when nothing matches exactly, and calls this when it's picked.

recent?readonly T[]—

Recent picks shown first on an empty query. Leave it out to remember this session's picks.

rememberRecent?number3

How many picks to remember when recent isn't given; 0 turns recents off.

presentation?"popover" | "sheet"'popover'

popover: an inline input with results anchored under it. sheet: the 1.x field that opens a searchable sheet.

highlightMatches?booleantrue

Bold the letters that match.

openOnFocus?booleantrue

Show results as soon as the input is focused.

clearable?booleantrue

A clear button in the input while it has text; clearing also clears the value.

maxListHeight?number320

The tallest the results may be, in points; they also stop above the keyboard.

helper?string—

Supporting text under the field.

error?string—

Validation message.

success?string—

Confirmation text; replaces the helper.

status?FieldStatus'idle'

Validation state shown on the field (loading shows the spinner too).

required?booleanfalse

Marks the field required.

requiredIndicator?FieldRequiredIndicator'asterisk'

How a required field is marked.

optionalIndicator?booleanfalse

Show "Optional" after the label.

disabled?booleanfalse

No typing or picking.

disabledStyle?FieldDisabledStyle'muted'

muted lightens the field; dim lowers it to 50%.

appearance?FieldAppearance'filled'

The field's surface.

size?FieldSize'md'

sm 36pt, md 44pt, lg 52pt.

shape?FieldShape'preset'

preset or pill.

labelPlacement?FieldLabelPlacement'above'

Where the label sits.

focusRing?FieldFocusRing'halo'

The ring and halo while focused.

leadingIcon?ButtonIcon—

A leading icon in the field (the chosen option's icon replaces it).

messages?Partial<ComboboxMessages>English

Built-in strings, for translation.

haptics?boolean | SelectionHapticstrue

Haptics: a switch, or per part (select for a pick, clear).

motion?MotionOverridethe app's feel

Field, list and highlight motion.

className?string—

Classes on the field.

style?StyleProp<ViewStyle>—

Field style.

testID?string—

The input's identifier. The list appends -option and rows -option-<value>; the create row -option-__create__.

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

PropDoesDefault
filterAccent-folded ranked matching, your own, or falsematchOptions
onQueryChange / debounceThe query once typing rests (ms)none, 200
loadingA spinner and "Searching…"false
onCreateA "Create “query”" rownone
recent / rememberRecentRecent picks first; how many to remembersession, 3
highlightMatchesBold matched letterstrue
openOnFocusOpen the results on focustrue
clearableA clear button while there's texttrue
maxListHeightTallest results (pt), within the room above the keyboard320
presentationpopover (inline) or the 1.x sheetpopover
appearance / size / shapeField lookfilled, md, preset
helper / error / successMessages under the fieldnone
required / disabledRequired mark; no typingfalse
hapticsAll, or { select, clear }select
messagesPlaceholder, "Searching…", create, "Recent", resultsEnglish

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, toggle and press motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items