Skip to content

Combobox

An input combined with a list of predefined items to select.

API Reference

Installation

pnpm dlx shadcn@latest add @frontal-labs/combobox

Usage

Single Selection

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox";
const items = [
  { value: "apple", label: "Apple" },
  { value: "banana", label: "Banana" },
  { value: "orange", label: "Orange" },
  { value: "grape", label: "Grape" },
]
 
<Combobox items={items}>
  <ComboboxInput placeholder="Select an item..." />
  <ComboboxContent>
    <ComboboxEmpty>No results found.</ComboboxEmpty>
    <ComboboxList>
      {(item) => <ComboboxItem key={item.value} value={item}>{item.label}</ComboboxItem>}
    </ComboboxList>
  </ComboboxContent>
</Combobox>

Multiple Selection

import {
  Combobox,
  ComboboxChip,
  ComboboxChips,
  ComboboxChipsInput,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxItem,
  ComboboxList,
  ComboboxValue,
} from "@/components/ui/combobox";
const items = [
  { value: "apple", label: "Apple" },
  { value: "banana", label: "Banana" },
  { value: "orange", label: "Orange" },
  { value: "grape", label: "Grape" },
]
 
<Combobox items={items} multiple>
  <ComboboxChips>
    <ComboboxValue>
      {(value: { value: string; label: string }[]) => (
        <>
          {value?.map((item) => (
            <ComboboxChip key={item.value} aria-label={item.value}>
              {item.label}
            </ComboboxChip>
          ))}
          <ComboboxChipsInput
            placeholder={value.length > 0 ? undefined : "Select an item..."}
            aria-label="Select an item"
          />
        </>
      )}
    </ComboboxValue>
  </ComboboxChips>
  <ComboboxContent>
    <ComboboxEmpty>No results found.</ComboboxEmpty>
    <ComboboxList>
      {(item) => <ComboboxItem value={item}>{item.label}</ComboboxItem>}
    </ComboboxList>
  </ComboboxContent>
</Combobox>

API Reference

Combobox

The root combobox component. Manages the combobox state and provides context to child components.

ComboboxInput

The input field component for single selection mode with extended features for size variants and addon support.

ComboboxContent

The popup container that displays the combobox options. The surface is elevated with shadow-menu and surface-ring.

About dark: the popup renders with the dark palette by default. Pass dark={false} when it should follow the ambient theme instead — next-themes sets dark on <html> and the portal lands in document.body, inside it, so the popup can pick up the ambient theme once dark is turned off. For a popup opened from a .dark region scoped mid-page, which a portal does escape, rendering into the scoped node is usually the better tool. dark applies .dark to the positioner inside the portal, so the tokens inherit down to the popup and everything within it.

ComboboxList

A scrollable container for combobox items.

ComboboxItem

An individual selectable combobox item.

ComboboxEmpty

Displays a message when no results are found.

ComboboxGroup

Groups related combobox items together.

ComboboxLabel

Displays a label for a combobox group. Styled wrapper for Combobox.GroupLabel from Base UI.

ComboboxCollection

Used to wrap items within a group for rendering.

ComboboxChips

Container for displaying selected chips in multiple selection mode.

ComboboxChipsInput

The input field component for use inside ComboboxChips in multiple selection mode. This is a minimal input without the wrapper, trigger, or clear button.

ComboboxChip

An individual chip representing a selected item in multiple selection mode.

ComboboxValue

Provides access to the current value for custom rendering.

Examples

Disabled

Small Size

Large Size

With Label

Auto Highlight

Automatically highlight the first matching option.

With Clear Button

With Groups

With Multiple Selection

With Input Inside Popup

With Select-like Button

Render ComboboxTrigger with a Button and put the ComboboxInput inside ComboboxContent to make the combobox read like a select.

Form Integration

Form Integration - Multiple