docs/components/combobox
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Displays a searchable list of options.
PreviewCode
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/combobox
Combobox
├── ComboboxInput
└── ComboboxContent
├── ComboboxEmpty
└── ComboboxList
└── ComboboxGroup
├── ComboboxGroupLabel
└── ComboboxItem
import { useFilter, useListCollection } from "@ark-ui/react";
import {
Combobox,
ComboboxContent,
ComboboxGroup,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox";
const { contains } = useFilter({ sensitivity: "base" });
const { collection, filter } = useListCollection({
initialItems: [
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
],
filter: contains,
});
<Combobox
collection={collection}
onInputValueChange={({ inputValue }) => filter(inputValue)}
>
<ComboboxInput placeholder="Select an option" />
<ComboboxContent>
<ComboboxList>
{items.map((item) => (
<ComboboxItem item={item} key={item.value}>
{item.label}
</ComboboxItem>
))}
</ComboboxList>
</ComboboxContent>
</Combobox>
Control the selected value with inputValue and onValueChange props.
PreviewCode
Selected: banana
PreviewCode
PreviewCode
PreviewCode
PreviewCode
PreviewCode
Automatically highlight the first matching item as the user types.
PreviewCode
PreviewCode
Use Combobox with Field components to style the combobox with the field components.
PreviewCode
Country
We'll use this for shipping estimates
PreviewCode
Enable multiple selection by setting the multiple prop to Combobox.
PreviewCode
Pass showClear to ComboboxInput to show a clear button.
PreviewCode
PreviewCode
Root component.
| Prop | Type | Default |
|---|---|---|
collection | ListCollection<T> | required |
value | `string | string[]` |
defaultValue | `string | string[]` |
onValueChange | (details: ValueChangeDetails<T>) => void | - |
onInputValueChange | (details: InputValueChangeDetails) => void | - |
multiple | boolean | false |
disabled | boolean | - |
openOnClick | boolean | true |
lazyMount | boolean | true |
unmountOnExit | boolean | true |
className | string | - |
Optional wrapper for custom layouts.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Input with dropdown trigger and optional clear button. Combines search and selection.
| Prop | Type | Default |
|---|---|---|
size | `"sm" | "md" |
showTrigger | boolean | true |
showClear | boolean | false |
disabled | boolean | - |
className | string | - |
Opens the dropdown on click.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Button to clear the input value.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
Holds the dropdown options. Displayed in a portal.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Wraps the list of options. Use with collection.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
A single selectable option.
| Prop | Type | Default |
|---|---|---|
item | T | required |
className | string | - |
asChild | boolean | - |
Groups related options under an optional heading.
| Prop | Type | Default |
|---|---|---|
heading | `string | ReactNode` |
className | string | - |
asChild | boolean | - |
Label for an option group.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Shown when no options match the current filter. Use for empty state.
| Prop | Type | Default |
|---|---|---|
className | string | - |
children | ReactNode | No results found. |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Color Picker ](/docs/components/color-picker)[
Next page
Command ](/docs/components/command)
On This Page
InstallationAnatomyUsageControlledSizeSmallMediumLargeStatesInvalidDisabledExamplesAuto highlightGroupWith FieldScrollableMultipleWith clear buttonWith start iconAPI ReferenceComboboxComboboxControlComboboxInputComboboxTriggerComboboxClearComboboxContentComboboxListComboboxItemComboboxGroupComboboxGroupLabelComboboxEmpty