Combobox

An input that filters a list of options while you type and lets you pick one. Use it when the list is long enough that a Select is hard to scan.

General

Pass the options and name the field with aria-label, or with a visible label.

Initial value and disabled options

Use initialValue to start with a selection. An option with disabled cannot be picked.

Empty text

Change what shows when nothing matches with emptyText.

Disabled

A disabled Combobox cannot be focused.

APIs

Combobox.Props

AttributeDescriptionTypeAccepted valuesDefault
optionsthe options to choose fromComboboxOption[]ComboboxOption-
valueselected value, to control the componentstring / null--
initialValueselected value at the startstring / null-null
onChangecalled with the chosen value, or null when it is cleared(value: string | null) => void--
onInputChangecalled with the text while the user types(text: string) => void--
filterdecides which options match the text(option, text) => boolean-contains, case insensitive
placeholdertext shown when the input is emptystring--
emptyTexttext shown when no option matchesstring-No results
disableddisable the componentboolean-false
...native props, passed to the inputInputHTMLAttributes'aria-label', 'name', 'id', ...-

ComboboxOption

type ComboboxOption = {
  value: string
  label?: string // shown in the list and in the input, `value` when missing
  disabled?: boolean
}

Ref

The ref points at the input.

Accessibility

The input has role="combobox" and points at the active option with aria-activedescendant. The list is a listbox of option elements.

KeyAction
Arrow Down and UpOpen the list, and move between the options
EnterChoose the active option
EscapeClose the list
TabClose the list and restore the text of the selection

A screen reader hears how many options match while the user types. Give the input a name with aria-label or aria-labelledby.

Edit this page on GitHub