Combobox
Type to filter a long list and pick one, with the first match ready for Enter.
Installation
npx shadcn@latest add @quireui/comboboxUsage
const customers = [
{ value: "northwind", label: "Northwind Traders" },
{ value: "globex", label: "Globex" },
];
<Combobox items={customers}>
<ComboboxInput placeholder="Search customers" />
<ComboboxContent>
{(c) => (
<ComboboxItem key={c.value} value={c}>
{c.label}
</ComboboxItem>
)}
</ComboboxContent>
</Combobox>Pass the full list as items and render one item in the function child: the combobox filters it as you type. Items shaped { value, label } need nothing else; for other shapes, pass itemToStringLabel.
Filtering
Matching ignores case and accents, and the first match is highlighted while you type, so typing a few letters and pressing Enter is enough. When nothing matches, the list says so instead of closing. Turn the highlight off with autoHighlight={false}, and change the empty text with empty on ComboboxContent.
Once something is chosen, a clear button appears in the field. The caret on the right opens the full list without typing.
Groups
Give items a list of groups, each with its own items, and render a ComboboxGroup per group with a ComboboxCollection inside. Groups with no matches disappear while filtering.
<Combobox items={regions}>
<ComboboxInput placeholder="Type a country" />
<ComboboxContent>
{(group) => (
<ComboboxGroup key={group.value} items={group.items}>
<ComboboxLabel>{group.value}</ComboboxLabel>
<ComboboxCollection>
{(c) => <ComboboxItem key={c.value} value={c}>{c.label}</ComboboxItem>}
</ComboboxCollection>
</ComboboxGroup>
)}
</ComboboxContent>
</Combobox>In a form
Inside a Field with a name, the chosen value is submitted with the form and required is validated like Input, with the error under the field and nothing below it moving.
Sizes
size on Combobox: sm, md (default) or lg, the same heights as Select and Input. The list follows the size, so results line up with what you typed.
Accessibility
The field is read as a combobox with its list, and the highlighted option is read as you move through it. The clear and show-all buttons have their own names.
| Key | Action |
|---|---|
| Typing | Filters the list and highlights the first match. |
| ↓ / ↑ | Opens the list, then moves the highlight. |
| Enter | Picks the highlighted option and closes. |
| Esc | Closes the list. With the list closed, clears the field. |
| Tab | Closes and moves on. Text typed without picking is dropped, so the field never holds a half-typed name. |
Home and End move the text cursor in the field, as in any text input.
Combobox or something else?
- Under about ten options, or people pick without searching: Select.
- Searching for actions to run, not a value to fill in: Command.
API reference
Combobox
Prop
Type
Also takes every prop of Base UI's Combobox.Root.
ComboboxGroup
Also takes every prop of Base UI's Combobox.Group.
ComboboxCollection
Also takes every prop of Base UI's Combobox.Collection.
ComboboxInput
The field: a text input with a clear button once something is chosen, and a list toggle.
Prop
Type
Also takes every prop of Base UI's Combobox.Input. Style it with [data-slot="combobox"].
ComboboxContent
Prop
Type
Also takes every prop of Base UI's Combobox.Popup. Style it with [data-slot="combobox-content"].
ComboboxItem
Also takes every prop of Base UI's Combobox.Item.
ComboboxLabel
Also takes every prop of Base UI's Combobox.GroupLabel.
ComboboxSeparator
Also takes every prop of Base UI's Combobox.Separator.