ui-kit0.0

Forms

Combobox

Search and pick without leaving the field.

Usage

An input that filters a list as you type. Matching ignores case and accents, and the matching part of each option is highlighted. The input keeps focus while the arrow keys move a highlight through the list.

Used for tax and invoice formatting. Try typing “turk” or “ire”.

When to use

  • Lists long enough that scrolling is slow: countries, people, projects.
  • People who know what they are looking for and would rather type than scroll.

Not for: five or six options (use a select), or free text that does not have to match a list (use an input).

Create an option

Add ComboboxCreate to offer a “Create” row when the typed text matches nothing exactly. Add the new option in your state in onCreate; the value becomes the typed text.

Not listed? Type its name and choose “Create”.

API

Combobox

PropTypeDefaultDescription
value / defaultValuestring—Selected value. '' means nothing selected.
onValueChange(value: string) => void—Called when an option is chosen or the selection is cleared.
inputValue / defaultInputValuestring—Text in the input. After a choice it shows the option label.
onInputValueChange(text: string) => void—Called as the text changes.
open / defaultOpen / onOpenChangeboolean—Control the list open state.
namestring—Submits the selected value with a form through a hidden input.
disabledbooleanfalseDisables the input.

ComboboxInput

PropTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Height: 32 / 36 / 44px.
clearablebooleanfalseShow a clear button while a value is selected.
showTriggerbooleantrueShow the chevron button that toggles the list.
...propsInputProps—Forwarded to the <input>, including placeholder, id and aria-label.

ComboboxItem / ComboboxCreate

PropTypeDefaultDescription
valuestring—Unique, non-empty value (ComboboxItem).
textValuestring—Plain text to filter on when children are not text.
onCreate(text: string) => void—ComboboxCreate: called with the typed text.

Also: ComboboxContent, ComboboxEmpty (shows when nothing matches), ComboboxGroup with a label (hides itself when none of its options match), ComboboxLabel and ComboboxSeparator.

Keyboard

KeyAction
TypeFilter the list; the first match is highlighted.
↓ / ↑Open the list, then move the highlight.
EnterChoose the highlighted option.
Esc (open)Close and restore the selected label.
Esc (closed)Clear the input and the value.

Accessibility

  • WAI-ARIA combobox with list autocomplete: the input has role="combobox", aria-expanded, aria-controls and aria-activedescendant; focus stays in the input.
  • The list is a listbox; when nothing matches it is replaced by the empty message.
  • The chevron and clear buttons are pointer helpers, outside the tab order.

Motion

  • The list rises 4px with a light blur in 150ms; the chevron turns over on the snappy spring.
  • Reduced motion keeps the state change and drops the movement.