Combobox
An input that filters a list and lets the user pick from it.
Installation
npx shadcn@latest add @blank/comboboxUsage
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"<Combobox items={frameworks}>
<ComboboxInput placeholder="Select a framework" />
<ComboboxContent>
<ComboboxList>
{(item) => (
<ComboboxItem key={String(item)} value={item}>
{String(item)}
</ComboboxItem>
)}
</ComboboxList>
<ComboboxEmpty>No framework found.</ComboboxEmpty>
</ComboboxContent>
</Combobox>Examples
Multiple
multiple keeps an array. Render the chosen values as ComboboxChips inside ComboboxChips, with ComboboxChipsInput for typing.
bugdocs
Clear and icon
showClear swaps the chevron for a clear button once there is a value; leadingIcon takes any icon.
Sizes
The same 32, 36 and 40 px as Input and Select.
API Reference
Combobox
Every div prop, plus:
| Prop | Type | Default |
|---|---|---|
items | unknown[] | [] |
value | unknown | unknown[] | — |
defaultValue | unknown | unknown[] | — |
onValueChange | (value: unknown | unknown[] | undefined) => void | — |
itemToStringValue | (item: unknown) => string | String(item) |
multiple | boolean | false |
open | boolean | — |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | — |
ComboboxInput
Every input prop except value and onChange, plus:
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
variant | "default" | "secondary" | "default" |
showTrigger | boolean | true |
showClear | boolean | false |
leadingIcon | ReactNode | — |
ComboboxChips
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
variant | "default" | "secondary" | "default" |
ComboboxList
children is either nodes or a function called once per item that matches the query.
ComboboxItem
| Prop | Type | Default |
|---|---|---|
value | unknown | — |