Skip to content

Combobox

Autocomplete input that filters a dropdown list as the user types. Built on React Aria ComboBox.

  • stable
  • since v0.1.0
  • 1.42 kB
  • form
  • input

Uses React Aria ComboBox; role="combobox" on input with aria-expanded and aria-controls pointing to the listbox.

Preview
Open
tsx

The input and its open/close chevron sit as raised tiles inside a segmented track, matching the other inputs. variant tints the track.

Control inputValue and items externally to implement server-side filtering.

Preview
Open
tsx

Use allowsCustomValue to let users enter values not present in the list.

Preview
Open
tsx
Preview
Open
tsx
PropTypeDefaultDescription
value
string|null
—
Controlled selected value. The current value (controlled).
defaultValue
string|null
—
Uncontrolled initial value. The default value (uncontrolled).
onValueChange
((value: T | null) => void)
—
Fires when the user selects an item (or clears the field, with `null`).
inputValue
string
—
Current text in the input — separate from the selected key.
defaultInputValue
string
—
Uncontrolled initial input text.
onInputChange
((value: string) => void)
—
Fires on every keystroke in the input.
placeholder
string
"Search…"
Placeholder rendered when the input is empty.
label
string
—
Visible label, also used as the trigger's accessible name when no aria-label is set.
aria-label
string
—
Aria label when no visual label is available. Defines a string value that labels the current element.
size
"sm"|"md"|"lg"
"md"
Control size.
variant
"outline"|"filled"|"ghost"
"outline"
Visual treatment.
disabled
boolean
—
Disables interaction.
required
boolean
—
Marks the field as required for form submission.
invalid
boolean
—
Renders the invalid state and sets `aria-invalid`.
allowsCustomValue
boolean
—
Allow values the user types that aren't in the list.
items
(readonly ComboboxItemData<T>[] & Iterable<object>)
—
Data-driven items; overrides `children`. The list of ComboBox items (controlled).
children
ReactNode
—
JSX children (`<ComboboxItem>`).
emptyState
ReactNode
—
Rendered when the filtered list is empty.
className
string
—
style
CSSProperties
—
name
string
—
The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
id
string
—
The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
ref
Ref<HTMLInputElement>
—
  • Built on React Aria ComboBox — role="combobox" on the input with aria-expanded, aria-controls, and aria-activedescendant wired automatically.
  • Keyboard: Arrow keys open/navigate the list, Enter selects, Escape clears and closes.
  • Empty state is announced to screen readers when no items match.
  • Use onInputChange + items to implement server-side search with debouncing.
  • Use allowsCustomValue when users may need to enter values not in the preset list (e.g. tag creation).