GitHub 560+

Combobox

Autocomplete input with a list of suggestions.

Installation

npx shadcn@latest add @fulldev/combobox

Usage

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
  ComboboxSeparator,
  ComboboxTrigger,
  ComboboxValue,
} from "@/components/ui/combobox"
<Combobox class="w-full max-w-sm">
  <ComboboxInput placeholder="Select a framework" />
  <ComboboxContent>
    <ComboboxEmpty>No items found.</ComboboxEmpty>
    <ComboboxList>
      <ComboboxItem value="nextjs">Next.js</ComboboxItem>
      <ComboboxItem value="sveltekit">SvelteKit</ComboboxItem>
      <ComboboxItem value="nuxt">Nuxt.js</ComboboxItem>
      <ComboboxItem value="remix">Remix</ComboboxItem>
      <ComboboxItem value="astro">Astro</ComboboxItem>
    </ComboboxList>
  </ComboboxContent>
</Combobox>

Composition

Use this composition for a single-line input and a flat list:

Combobox
├── ComboboxInput
└── ComboboxContent
    ├── ComboboxEmpty
    └── ComboboxList
        ├── ComboboxItem
        └── ComboboxItem

Use ComboboxGroup, ComboboxLabel, and ComboboxSeparator to organize items:

Combobox
├── ComboboxInput
└── ComboboxContent
    ├── ComboboxEmpty
    └── ComboboxList
        ├── ComboboxGroup
        │   ├── ComboboxLabel
        │   ├── ComboboxItem
        │   └── ComboboxItem
        ├── ComboboxSeparator
        └── ComboboxGroup
            ├── ComboboxLabel
            ├── ComboboxItem
            └── ComboboxItem

Use ComboboxTrigger and ComboboxValue when composing a custom trigger. Use showClear on ComboboxInput when the input needs a clear control.

Examples

Auto Highlight

Use autoHighlight to automatically highlight the first visible item after a non-whitespace query.

Combobox in Popup

Trigger the combobox from a button and move the search input inside the popup.

Disabled

Use disabled on Combobox to disable interaction.

API Reference

See the GitHub source code for more information on props. See the data-slot docs for more information on interactivity.