--- title: Combobox description: Autocomplete input with a list of suggestions. base: base component: true links: doc: https://base-ui.com/react/components/combobox api: https://base-ui.com/react/components/combobox#api-reference --- ## Installation Command Manual ```bash npx shadcn@latest add combobox ``` Install the following dependencies: ```bash npm install @base-ui/react ``` 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. {(item) => ( {item} )} ) } ``` ## Custom Items Use `itemToStringValue` when your items are objects. ```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 ( framework.label} > No items found. {(framework) => ( {framework.label} )} ) } ``` ## Multiple Selection Use `multiple` with chips for multi-select behavior. ```tsx showLineNumbers import * as React from "react" import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, ComboboxValue, } from "@/components/ui/combobox" const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"] export function ExampleComboboxMultiple() { const [value, setValue] = React.useState([]) return ( {value.map((item) => ( {item} ))} No items found. {(item) => ( {item} )} ) } ``` ## Examples ### 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 `aria-invalid` prop to make the combobox invalid. ### Disabled Use the `disabled` prop to disable the combobox. ### Auto Highlight Use the `autoHighlight` prop automatically highlight the first item on filter. ### Popup You can trigger the combobox from a button or any other component by using the `render` prop. Move the `ComboboxInput` inside the `ComboboxContent`. ### Input Group You can add an addon to the combobox by using the `InputGroupAddon` component inside the `ComboboxInput`. ## API Reference See the [Base UI](https://base-ui.com/react/components/combobox#api-reference) documentation for more information.