Live example

Type to filter, or use the arrow keys.

Selected value: lumen-city

Usage
<Combobox
  label="Trip type"
  options={[{ value: 'beach', label: 'Beach' }, { value: 'city', label: 'City' }]}
  value={type}
  onChange={setType}
/>

Props

Combobox props
PropTypeDefaultDescription
labelstringnoneVisible label, also names the listbox.
optionsComboboxOption[]nonevalue, label, optional description and disabled.
value?string | nullnoneControlled selected value.
defaultValue?string | nullnullUncontrolled initial value.
onChange?(value: string | null) => voidnoneCalled on selection, or with null when cleared.
error?stringnoneError message tied to the input.
emptyMessage?string'No matches'Shown and announced when the filter matches nothing.
required?booleannoneAdds aria-required and the visible marker.

Do and don't

Do

  • Use for lists longer than about seven options.
  • Keep option labels short and distinct at the start.

Don't

  • Use for two or three options; use RadioGroup.
  • Accept free text silently; this component reverts to the last valid choice.

Accessibility

  • Input has role combobox with aria-expanded, aria-controls and aria-autocomplete="list".
  • Focus stays in the input. The active option is exposed with aria-activedescendant.
  • The number of matching options is announced in a polite live region as you type.

Keyboard

Combobox keyboard support
KeysAction
Down ArrowOpens the list, or moves to the next option
Up ArrowMoves to the previous option
Alt + Down ArrowOpens the list without moving
EnterSelects the active option and closes
EscapeCloses the list; pressed again, clears the value
TabCloses the list and keeps the current value