Components

Combobox

An input that filters a list and lets the user pick from it.

Installation

npx shadcn@latest add @blank/combobox

Usage

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox"
<Combobox items={frameworks}>
  <ComboboxInput placeholder="Select a framework" />
  <ComboboxContent>
    <ComboboxList>
      {(item) => (
        <ComboboxItem key={String(item)} value={item}>
          {String(item)}
        </ComboboxItem>
      )}
    </ComboboxList>
    <ComboboxEmpty>No framework found.</ComboboxEmpty>
  </ComboboxContent>
</Combobox>

Examples

Multiple

multiple keeps an array. Render the chosen values as ComboboxChips inside ComboboxChips, with ComboboxChipsInput for typing.

bugdocs

Clear and icon

showClear swaps the chevron for a clear button once there is a value; leadingIcon takes any icon.

Sizes

The same 32, 36 and 40 px as Input and Select.

API Reference

Combobox

Every div prop, plus:

PropTypeDefault
itemsunknown[][]
valueunknown | unknown[]—
defaultValueunknown | unknown[]—
onValueChange(value: unknown | unknown[] | undefined) => void—
itemToStringValue(item: unknown) => stringString(item)
multiplebooleanfalse
openboolean—
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void—

ComboboxInput

Every input prop except value and onChange, plus:

PropTypeDefault
size"sm" | "default" | "lg""default"
variant"default" | "secondary""default"
showTriggerbooleantrue
showClearbooleanfalse
leadingIconReactNode—

ComboboxChips

PropTypeDefault
size"sm" | "default" | "lg""default"
variant"default" | "secondary""default"

ComboboxList

children is either nodes or a function called once per item that matches the query.

ComboboxItem

PropTypeDefault
valueunknown—