import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"]
export function ExampleCombobox() {
return (
<Combobox allowsEmptyCollection>
<ComboboxInput placeholder="Select a framework" />
<ComboboxContent>
<ComboboxList
renderEmptyState={() => (
<ComboboxEmpty>No items found.</ComboboxEmpty>
)}
>
{frameworks.map((item) => (
<ComboboxItem key={item} id={item}>
{item}
</ComboboxItem>
))}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
A single-line input and a flat list (see Basic).
Combobox
├── ComboboxInput
└── ComboboxContent
└── ComboboxList
├── ComboboxItem
└── ComboboxItem
Multi-select with multiple, chips, and a chips input (see Multiple).
Combobox
├── ComboboxChips
│ ├── ComboboxChipList
│ │ └── ComboboxChip
│ └── ComboboxChipsInput
└── ComboboxContent
└── ComboboxList
├── ComboboxItem
└── ComboboxItem
Nested items per group using ComboboxGroup, with a separator between groups (see Groups).
Combobox
├── ComboboxInput
└── ComboboxContent
└── ComboboxList
├── ComboboxGroup
│ ├── ComboboxLabel
│ ├── ComboboxItem
│ └── ComboboxItem
├── ComboboxSeparator
└── ComboboxGroup
├── ComboboxLabel
├── ComboboxItem
└── ComboboxItem
Use textValue when your items render JSX children.
import * as React from "react"
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
type Framework = {
label: string
value: string
}
const frameworks: Framework[] = [
{ label: "Next.js", value: "next" },
{ label: "SvelteKit", value: "sveltekit" },
{ label: "Nuxt", value: "nuxt" },
]
export function ExampleComboboxCustomItems() {
return (
<Combobox allowsEmptyCollection>
<ComboboxInput placeholder="Select a framework" />
<ComboboxContent>
<ComboboxList
renderEmptyState={() => (
<ComboboxEmpty>No items found.</ComboboxEmpty>
)}
items={frameworks}
>
{(framework) => (
<ComboboxItem id={framework.value} textValue={framework.label}>
<span>{framework.label}</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
Use multiple with chips for multi-select behavior.
import * as React from "react"
import {
Combobox,
ComboboxChip,
ComboboxChipList,
ComboboxChips,
ComboboxChipsInput,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"
const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"]
export function ExampleComboboxMultiple() {
const [value, setValue] = React.useState<string[]>([])
return (
<Combobox
selectionMode="multiple"
value={value}
onChange={setValue}
allowsEmptyCollection
>
<ComboboxChips>
<ComboboxChipList<{ name: string }>>
{(value) => <ComboboxChip id={value.name}>{value.name}</ComboboxChip>}
</ComboboxChipList>
<ComboboxChipsInput placeholder="Add framework" />
</ComboboxChips>
<ComboboxContent>
<ComboboxList
renderEmptyState={() => (
<ComboboxEmpty>No items found.</ComboboxEmpty>
)}
>
{frameworks.map((item) => (
<ComboboxItem key={item} id={item}>
{item}
</ComboboxItem>
))}
</ComboboxList>
</ComboboxContent>
</Combobox>
)
}
A simple combobox with a list of frameworks.
A combobox with multiple selection using multiple and ComboboxChips.
Use the showClear prop to show a clear button.
Use ComboboxGroup and ComboboxSeparator to group items.
You can render custom component inside ComboboxItem.
Use the isInvalid prop to make the combobox invalid.
Use the isDisabled prop to disable the combobox.
You can add an addon to the combobox by using the InputGroupAddon component inside the ComboboxInput.
To enable RTL support, see the RTL configuration guide.
See the React Aria documentation for more information.