--- title: Combobox description: Autocomplete input with a list of suggestions. base: aria component: true links: doc: https://react-aria.adobe.com/ComboBox api: https://react-aria.adobe.com/ComboBox#api --- ## Installation Command Manual ```bash npx shadcn@latest add combobox ``` Install the following dependencies: ```bash npm install react-aria-components ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@/components/ui/combobox" ``` ```tsx showLineNumbers const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"] export function ExampleCombobox() { return ( ( No items found. )} > {frameworks.map((item) => ( {item} ))} ) } ``` ## Composition ### Simple A single-line input and a flat list (see [Basic](#basic)). ```text Combobox ├── ComboboxInput └── ComboboxContent └── ComboboxList ├── ComboboxItem └── ComboboxItem ``` ### With chips Multi-select with `multiple`, chips, and a chips input (see [Multiple](#multiple)). ```text Combobox ├── ComboboxChips │ ├── ComboboxChipList │ │ └── ComboboxChip │ └── ComboboxChipsInput └── ComboboxContent └── ComboboxList ├── ComboboxItem └── ComboboxItem ``` ### With groups and collection Nested items per group using `ComboboxGroup`, with a separator between groups (see [Groups](#groups)). ```text Combobox ├── ComboboxInput └── ComboboxContent └── ComboboxList ├── ComboboxGroup │ ├── ComboboxLabel │ ├── ComboboxItem │ └── ComboboxItem ├── ComboboxSeparator └── ComboboxGroup ├── ComboboxLabel ├── ComboboxItem └── ComboboxItem ``` ## Custom Items Use `textValue` when your items render JSX children. ```tsx showLineNumbers 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 ( ( No items found. )} items={frameworks} > {(framework) => ( {framework.label} )} ) } ``` ## Multiple Selection Use `multiple` with chips for multi-select behavior. ```tsx showLineNumbers 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([]) return ( > {(value) => {value.name}} ( No items found. )} > {frameworks.map((item) => ( {item} ))} ) } ``` ## Basic A simple combobox with a list of frameworks. ## Multiple A combobox with multiple selection using `multiple` and `ComboboxChips`. ## Clear Button Use the `showClear` prop to show a clear button. ## Groups Use `ComboboxGroup` and `ComboboxSeparator` to group items. ## Custom Items You can render custom component inside `ComboboxItem`. ## Invalid Use the `isInvalid` prop to make the combobox invalid. ## Disabled Use the `isDisabled` prop to disable the combobox. ## Input Group You can add an addon to the combobox by using the `InputGroupAddon` component inside the `ComboboxInput`. ## RTL To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl). ## API Reference See the [React Aria](https://react-aria.adobe.com/ComboBox#api) documentation for more information.