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
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | string | — | Selected value. '' means nothing selected. |
| onValueChange | (value: string) => void | — | Called when an option is chosen or the selection is cleared. |
| inputValue / defaultInputValue | string | — | Text in the input. After a choice it shows the option label. |
| onInputValueChange | (text: string) => void | — | Called as the text changes. |
| open / defaultOpen / onOpenChange | boolean | — | Control the list open state. |
| name | string | — | Submits the selected value with a form through a hidden input. |
| disabled | boolean | false | Disables the input. |
ComboboxInput
| Prop | Type | Default | Description |
|---|---|---|---|
| size | 'sm' | 'md' | 'lg' | 'md' | Height: 32 / 36 / 44px. |
| clearable | boolean | false | Show a clear button while a value is selected. |
| showTrigger | boolean | true | Show the chevron button that toggles the list. |
| ...props | InputProps | — | Forwarded to the <input>, including placeholder, id and aria-label. |
ComboboxItem / ComboboxCreate
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | Unique, non-empty value (ComboboxItem). |
| textValue | string | — | 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
| Key | Action |
|---|---|
| Type | Filter the list; the first match is highlighted. |
| ↓ / ↑ | Open the list, then move the highlight. |
| Enter | Choose 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.