Faber UI
Components

Combobox

A searchable input with a popup list of options.

Combobox is built on the Base UI Combobox primitive. Pass an items array to the root and render items with a function child so the list can filter and show an empty state.

typescript
"use client";

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox";

const fruits = [
  { label: "Apple", value: "apple" },
  { label: "Banana", value: "banana" },
];

export default function Example() {
  return (
    <Combobox items={fruits}>
      <ComboboxInput placeholder="Search a fruit..." className="w-56" />
      <ComboboxContent>
        <ComboboxEmpty>No results.</ComboboxEmpty>
        <ComboboxList>
          {(item) => (
            <ComboboxItem key={item.value} value={item}>
              {item.label}
            </ComboboxItem>
          )}
        </ComboboxList>
      </ComboboxContent>
    </Combobox>
  );
}

Installation

Terminal
pnpm dlx shadcn@latest add https://faber-ui.vercel.app/r/combobox.json

Examples

Default

With groups

API

Each part forwards every prop of what it is built on, including className and render where Base UI supports it. The props column lists only what Faber UI adds on top.

PartBuilt onProps
ComboboxCombobox.RootBase UI—
ComboboxValuedata-slot="combobox-value"Combobox.ValueBase UI—
ComboboxTriggerdata-slot="combobox-trigger"Combobox.TriggerBase UI—
ComboboxInputCombobox.InputBase UI
  • showTrigger? = trueboolean
  • showClear? = falseboolean
ComboboxContentdata-slot="combobox-content"Combobox.PopupBase UI
  • side? = "bottom"Combobox.Positioner["side"]
  • align? = "start"Combobox.Positioner["align"]
  • sideOffset? = 6Combobox.Positioner["sideOffset"]
  • alignOffset? = 0Combobox.Positioner["alignOffset"]
  • anchor?Combobox.Positioner["anchor"]
ComboboxListdata-slot="combobox-list"Combobox.ListBase UI—
ComboboxItemdata-slot="combobox-item"Combobox.ItemBase UI—
ComboboxGroupdata-slot="combobox-group"Combobox.GroupBase UI—
ComboboxLabeldata-slot="combobox-label"Combobox.GroupLabelBase UI—
ComboboxCollectiondata-slot="combobox-collection"Combobox.CollectionBase UI—
ComboboxEmptydata-slot="combobox-empty"Combobox.EmptyBase UI—
ComboboxSeparatordata-slot="combobox-separator"Combobox.SeparatorBase UI—
ComboboxChipsdata-slot="combobox-chips"Combobox.ChipsBase UI—
ComboboxChipdata-slot="combobox-chip"Combobox.ChipBase UI
  • showRemove? = trueboolean
ComboboxChipsInputdata-slot="combobox-chip-input"Combobox.InputBase UI—
useComboboxAnchorHook—
ComponentDescription
ComboboxRoot. Accepts value, defaultValue, onValueChange.
ComboboxInputThe search input. Also acts as the popup trigger.
ComboboxContentThe popup container.
ComboboxListThe scrollable list of items.
ComboboxItemA single option. Accepts value.
ComboboxGroupGroups related items.
ComboboxLabelNon-interactive label for a group.
ComboboxEmptyShown when there are no results.
ComboboxSeparatorHorizontal divider.
ComboboxChipsContainer for selected value chips (multi-select).
ComboboxChipA single chip.
ComboboxChipsInputThe input rendered inside the chips container.
ComboboxTriggerThe trigger button.
ComboboxValueDisplays the selected value(s).

Changelog

  1. v0.3.0Popover, DropdownMenu, ContextMenu, Menubar, Select, Combobox, HoverCard, Tooltip, Dialog and AlertDialog enter and exit with interruptible transitions on the kit easing tokens, and tw-animate-css is no longer a depen…minor
  2. v0.3.0Input, Textarea, NativeSelect, CommandInput and ComboboxChipsInput use 16px text on small screens so iOS Safari no longer zooms the page on focus.patch
  3. v0.3.0KbdGroup is typed as a kbd element, Combobox imports its Base UI subpath, the motion lib mirrors the exit easing and travel tokens, and the chart item declares its react-is peer.patch
  4. v0.1.0Restore open and close animations on every menu-family popup.patch
Full Combobox history

Last updated on

On this page