Combobox
Combobox lets people type to narrow a long list of options and then pick one.
<Combobox items={regions}> <ComboboxInput placeholder="Search regions" /> <ComboboxContent> <ComboboxEmpty>No region matches.</ComboboxEmpty> <ComboboxList> {(region) => ( <ComboboxItem value={region}>{region}</ComboboxItem> )} </ComboboxList> </ComboboxContent></Combobox>Use a Combobox when the list of options is too long to scan, such as countries, time zones or team members. The person types a few letters, the list shrinks to the options that match, and they pick one. For a short list of about ten options or fewer, use Select. To run commands rather than choose a value, use Command.
The typed text only filters the list. It never becomes the value, so a form always receives one of your options. Matching compares the text against each option's label and keeps the options that contain it. For this reason ComboboxList accepts a function rather than children: you describe how to render one option, and the list renders only the options that match.
Pass every option in items. An option is either a string or an object with a value and a label, in which case people search and read the label and the form receives the value. Keep the items array stable by defining it outside your component or in a useMemo, because a new array on every render makes the filter run again.
Set name, required, disabled, readOnly and form on Combobox, because the chosen value belongs to the root. The field looks and behaves like a TextField, and the panel matches the panel of a Select. size sets both, and each size matches a TextField or a Button of the same size. Inside a Field, the field's size applies unless you set one.
The input has the combobox role and tells a screen reader whether the list is open. The arrow keys move through the options, Enter picks the highlighted one, and Escape closes the panel. After you type, the first match is highlighted, so a few letters and Enter are enough. The list takes its accessible name from the field, such as a Field label or the input's aria-label.
The part names follow shadcn/ui's combobox (MIT), and the behaviour comes from Base UI's Combobox.
- Select when the list is short enough to scan.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Typing and picking
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | A <ComboboxInput> and a <ComboboxContent>. |
defaultOpen? | boolean | Whether the panel is open at the start, when the combobox controls it. |
defaultValue? | T | null | The option chosen at the start, when the combobox controls its own value. |
disabled? | boolean | Turns off the whole control. |
form? | string | The id of the form that the field belongs to. |
items | readonly (T | ComboboxOptionGroup<T>)[] | All the options, as a flat list or as groups ({ value, items }). |
name? | string | The name of the field when a form is submitted. |
onOpenChange? | (open: boolean, details: ComboboxOpenChangeDetails) => void | Called when the panel opens or closes. |
onValueChange? | (value: T | null) => void | Called when the chosen option changes. |
open? | boolean | Whether the panel is open, when you control it. |
readOnly? | boolean | Shows and submits the value, but you can't change it. |
required? | boolean | Makes a chosen option necessary before the form can submit. |
size? | "1" | "2" | "3" | "4" | Sets the size step of the field and the panel. |
value? | T | null | The chosen option, when you control it. |
ComboboxInput
The field that people type in. className and style apply to the visible box, and ref points to the input inside it. The chevron at the end opens the list with a pointer, and the keyboard opens it with the arrow keys
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when the field sits over other content, such as an image. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
leading? | React.ReactNode | Content before the text, such as an icon or a unit. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
It also takes every prop of a <input>.
Showing the panel
ComboboxContent
The panel that holds the list. It opens below the field, renders in a portal with your theme settings, and is never narrower than the field
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | A <ComboboxList> and a <ComboboxEmpty>. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
It also takes every prop of a <div>.
Listing the options
ComboboxList
The list of options. It accepts a function and calls it once for each option that matches, and it takes its accessible name from the field unless you give it one
| Prop | Type | What it does |
|---|---|---|
aria-label? | string | The accessible name of the list of options. |
aria-labelledby? | string | The id of an element that names the list, where the words are already on screen. |
children | (item: T, index: number) => React.ReactNode | A function that renders one option or group. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
ComboboxItem
One option. Space for the tick is always kept, so chosen and unchosen rows line up. Write the option's label as its text, because the field shows that label after a choice
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The text of the row. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
disabled? | boolean | Turns off the option, so you can't choose it. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
value | ComboboxOption | The option that this row chooses. |
ComboboxEmpty
The message shown when no option matches. A screen reader announces it when it appears, and it takes up no space while it is empty
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The message that the panel shows when no option matches. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
Grouping options into sections
ComboboxGroup
A section with its own options. When no option in the section matches, the section and its heading are hidden
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | A ComboboxLabel that names the group, and a ComboboxCollection that renders its options. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
items | readonly ComboboxOption[] | The options in this group. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
ComboboxLabel
A heading above a set of options. It works inside a group or on its own, and the keyboard skips over it
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | The name of the group. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
- Free text with suggestions — A Combobox always submits one of your options and never the typed text. For a command palette, use
Command. A text field that accepts any text and offers suggestions is not available yet. multiple— Choosing several values would need removable chips inside the field, and that design does not exist yet. For now, use a group of checkboxes in aField.- A custom matcher, a result limit and inline completion — The typed text always filters the options by label. To match in a different way, filter the options yourself and pass the shorter list to
items. disabled,readOnly,name,requiredandformon the input — Set these onCombobox. On the input they would act on the typed letters rather than the chosen option, so the form would submit the wrong value.- A Separator inside the panel — A list of options may contain only options and groups, so a separator fails accessibility checks. Use
ComboboxGroupto divide the options instead. renderon the input — The field is two elements, a visible box and the input inside it, so arenderprop could only replace one of them. UseclassNameandstylefor the box andreffor the input.- A clear button — The chevron fills the end of the field, and a clear button beside it has not been designed yet. A person can select the text and delete it to clear the choice.