sc1m/design
ComponentsCombobox

Combobox

Combobox component built on Base UI, styled with sc1m tokens.

StableBase UI

Live preview

Installation

pnpm dlx shadcn@latest add @sc1m/combobox

This also merges the token layer and installs src/lib/cn.ts plus @base-ui/react. For the manual route — prerequisites, components.json, and app-level setup — see Installation.

Usage

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

Composition

Every part is a separate export. Combobox owns state; the rest are presentational and must appear in this order.

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

Example

The preview above, with its source. This is the demo module verbatim, so the code and the thing it renders cannot drift apart.

<Combobox items={fruits}>
  <ComboboxInput placeholder="Search fruits…" />
  <ComboboxContent>
    <ComboboxEmpty>No fruits found.</ComboboxEmpty>
    <ComboboxList>
      {(fruit: string) => (
        <ComboboxItem key={fruit} value={fruit}>
          {fruit}
        </ComboboxItem>
      )}
    </ComboboxList>
  </ComboboxContent>
</Combobox>

API reference

Each part forwards every prop of its Base UI counterpart; the tables list the ones declared on the part itself. See Base UI's reference for the inherited element props.

ComboboxInput

PropTypeDefaultDescription
disabledbooleanfalseWhether the component should ignore user interaction.

ComboboxContent

PropTypeDefaultDescription
initialFocusboolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the popup is opened.
finalFocusboolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the popup is closed.

ComboboxItem

PropTypeDefaultDescription
onClickBaseUIComponentProps<'div', ComboboxItemState>['onClick']An optional click handler for the item when selected.
indexnumberThe index of the item in the list.
valueanynullA unique value that identifies this item.
disabledbooleanfalseWhether the component should ignore user interaction.

Accessibility

Behaviour, focus management, and ARIA wiring come from Base UI's Combobox — see its reference for the full keyboard map.

  • Keyboard focus draws a 2px ring in --ring, never removed — only shown on :focus-visible, so a pointer press does not paint one.
  • Disabled parts mute their contents rather than the element, keeping the focus ring at full strength where the part stays focusable.

Design tokens

The component reads semantic tokens only — no raw colour, radius, or duration appears in its source. Override the token, not the component.

TokenApplied to
--accentComboboxItem
--brand-radius-mdComboboxInput, ComboboxContent
--brand-radius-smComboboxItem
--fgComboboxInput, ComboboxContent, ComboboxItem
--fg-subtleComboboxInput, ComboboxEmpty
--lineComboboxInput, ComboboxContent
--ringComboboxInput
--shadow-overlayComboboxContent
--surfaceComboboxItem
--surface-raisedComboboxInput, ComboboxContent

Source

src/components/ui/combobox/combobox.tsx — no next/* imports, so it drops into any React 19 + Tailwind v4 app.