Combobox
A field you type into to find an option in a long list. Typing filters the list and bolds what matched, ignoring case and accents, so “cura” finds Curaçao. With multiple, choices become chips inside the field.
Install
npx shadcn@latest add @nelumbo/comboboxVariants
The same field as Input and Select. Type to filter, ↑ and ↓ to move, Enter to choose, Escape to put the old value back. Country codes match too: try “ch”.
filled
Where your invoices are sent.
outlined
Where your invoices are sent.
Multiple
Choices become chips and the field grows when they wrap. The list stays open while you pick, and Backspace in the empty input removes the last chip.
filled
2 selected
outlined
2 selected
Groups, icons and descriptions
Options with a group are listed under it. Icons and descriptions show in the list; disabled options are skipped by the keyboard.
Icons at the end
iconPosition="end" puts icons at the far end, opposite the label, for the whole list or per option. In a single choice, the check moves to the start.
Nested
Options with children open level by level. Cascade (the default) opens each level beside its parent, like a desktop menu; drill shows one level at a time with a back row. → or Enter goes in, ← comes back. Typing searches every level at once and groups the matches by path: try “nor” or “nordics”. A parent shows what you chose inside it. On a phone it always drills.
single
multiple
const locations = [ { value: "europe", label: "Europe", icon: "euro", children: [ { value: "nordics", label: "Nordics", children: ["Denmark", "Finland", "Sweden"] }, { value: "western", label: "Western Europe", children: ["France", "Ireland"] }, ], }, { value: "remote", label: "Anywhere (remote)" },]<Combobox label="Office" options={locations} value={office} onValueChange={setOffice} />Searching a server
Turn off local filtering with filter={false}, search in onInputValueChange, and set loading while the request runs.
const [query, setQuery] = React.useState("")const { data = [], isLoading } = useQuery({ queryKey: ["cities", query], queryFn: () => searchCities(query) })<Combobox label="City" options={data} filter={false} loading={isLoading} onInputValueChange={setQuery} value={city} onValueChange={setCity}/>In a form
Give it a name to submit the value, one entry per chip with multiple.
Usage
import { Combobox } from "@/components/ui/combobox"// options are strings, or { value, label, description?, icon?, group?, keywords?, disabled? }<Combobox label="Country" options={countries} value={country} onValueChange={setCountry} /><Combobox multiple label="Labels" options={["Bug", "Design", "Docs"]} value={labels} onValueChange={setLabels} />Props
| Prop | Type | Default | Notes |
|---|---|---|---|
options | (string | ComboboxOption)[] | { value, label, description?, icon?, iconPosition?, group?, keywords?, disabled?, children? } | |
option children | (string | ComboboxOption)[] | Makes it a parent that opens a nested panel | |
iconPosition | "start" | "end" | "start" | Option icons before the label or at the far end |
nestedStyle | "cascade" | "drill" | "cascade" | Side menus, or one panel at a time; phones always drill |
searchable | boolean | true | false makes it a select (NestedSelect) |
displayPath | boolean | false | Show the chosen option's path in the field |
value / defaultValue | string | null, or string[] with multiple | onValueChange gets the same type | |
multiple | boolean | false | Chips in the field; the list stays open |
inputValue / onInputValueChange | string / (text) => void | The typed text | |
filter | false | (option, query) => boolean | label and keywords, ignoring case and accents | false for server search |
loading | boolean | false | Spinner in the field, and in an empty list |
emptyMessage | ReactNode | "No results" | |
clearable | boolean | true | Clear button once there's a value |
name | string | Hidden input(s) for forms | |
label, variant, size, icon, description, error | As on Input |