Skip to main content

Combobox

A searchable single and multi-chip combobox with a viewport-aware portal dropdown, spring hover highlight, stroke-draw checkmark, and IME-safe keyboard selection.

selected=nextjs

Customize

SizeDefault
Blur radius (px)4
Side offset (px)6
Speed1

Installation

npx shadcn@latest add @kinetic/combobox

Usage

Combobox supports both a flat items prop and a declarative compound API (ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem, ComboboxGroup, ComboboxChips, useComboboxAnchor). Pass items as strings or as option objects with value and label:

import { Combobox } from "@/components/kinetic/ui/combobox";

const frameworks = ["Next.js", "Remix", "Astro", "Vite"];

export function FrameworkPicker() {
  return (
    <Combobox
      items={frameworks}
      placeholder="Select a framework"
      aria-label="Framework"
    />
  );
}

Options

Option objects support description and disabled in addition to value and label.

<Combobox
  aria-label="Plan"
  items={[
    { value: "free", label: "Free", description: "For personal projects" },
    { value: "pro", label: "Pro", description: "For teams" },
    { value: "enterprise", label: "Enterprise", disabled: true },
  ]}
/>

Controlled value

In single mode, value is a string or null, and onValueChange receives the same type. Use defaultValue for an uncontrolled field.

const [value, setValue] = React.useState<string | null>(null);

<Combobox items={frameworks} value={value} onValueChange={setValue} aria-label="Framework" />

Multiple selection

Set multiple to select several items shown as chips. value, defaultValue, and onValueChange then use string[]. Backspace in an empty search field removes the last chip.

<Combobox
  multiple
  items={frameworks}
  defaultValue={["Next.js"]}
  aria-label="Frameworks"
/>

Empty state and clearing

Use emptyText to customize the message when no item matches the search (default "No results found."). placeholder defaults to "Select an option...". showClear controls the clear button and is on by default.

<Combobox items={frameworks} emptyText="No framework found" showClear={false} aria-label="Framework" />

Sizes and states

size accepts sm, default (default), or lg. Use invalid and disabled for validation and unavailable states, and name to submit the value with a form (in multiple mode, one hidden field per selected value).

<Combobox size="sm" items={frameworks} aria-label="Small" />
<Combobox invalid items={frameworks} aria-label="Required" />
<Combobox disabled items={frameworks} aria-label="Disabled" />

Compound API

Pass children to Combobox to compose custom inputs, grouped lists, empty states, and multi-chip selectors. Use ComboboxInput (showTrigger defaults to true, showClear defaults to false), ComboboxContent, ComboboxList (static JSX or a render function (item, index) => ReactNode over filtered items), ComboboxGroup (auto-hides when no item matches), ComboboxLabel, ComboboxSeparator, ComboboxCollection, ComboboxEmpty, ComboboxTrigger, ComboboxClear, and ComboboxValue. For multi-chip pickers, attach useComboboxAnchor() to ComboboxChips and pass anchor to ComboboxContent.

import {
  Combobox,
  ComboboxChip,
  ComboboxChips,
  ComboboxChipsInput,
  ComboboxCollection,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
  ComboboxSeparator,
  ComboboxValue,
  useComboboxAnchor,
} from "@/components/kinetic/ui/combobox";

interface RuntimePickerProps {
  defaultValue?: string;
}

export function RuntimePicker({ defaultValue = "node" }: RuntimePickerProps) {
  return (
    <Combobox defaultValue={defaultValue}>
      <ComboboxInput placeholder="Filter runtime..." showClear aria-label="Runtime" />
      <ComboboxContent>
        <ComboboxList>
          <ComboboxEmpty>No matching runtime.</ComboboxEmpty>
          <ComboboxGroup>
            <ComboboxLabel>Server</ComboboxLabel>
            <ComboboxCollection>
              <ComboboxItem value="node">Node.js</ComboboxItem>
              <ComboboxItem value="bun">Bun</ComboboxItem>
            </ComboboxCollection>
          </ComboboxGroup>
          <ComboboxSeparator />
          <ComboboxGroup heading="Edge">
            <ComboboxItem value="deno" keywords={["runtime", "ts"]}>
              Deno
            </ComboboxItem>
          </ComboboxGroup>
        </ComboboxList>
      </ComboboxContent>
    </Combobox>
  );
}

interface TagChipsPickerProps {
  items: string[];
}

export function TagChipsPicker({ items }: TagChipsPickerProps) {
  const anchor = useComboboxAnchor();
  return (
    <Combobox multiple items={items} defaultValue={[items[0]]}>
      <ComboboxChips ref={anchor}>
        <ComboboxValue>
          {(selected) =>
            Array.isArray(selected)
              ? selected.map((val) => (
                  <ComboboxChip key={val} value={val} showRemove>
                    {val}
                  </ComboboxChip>
                ))
              : null
          }
        </ComboboxValue>
        <ComboboxChipsInput placeholder="Add tags..." />
      </ComboboxChips>
      <ComboboxContent anchor={anchor}>
        <ComboboxEmpty>No matching tags.</ComboboxEmpty>
        <ComboboxList>
          {(item: string) => (
            <ComboboxItem key={item} value={item}>
              {item}
            </ComboboxItem>
          )}
        </ComboboxList>
      </ComboboxContent>
    </Combobox>
  );
}

Keyboard

Arrow keys move the highlight (ArrowDown or ArrowUp also opens the list), Home and End jump to the first and last enabled item, Enter selects, Escape closes the list, and Tab closes it while open. Selection is safe during IME composition. The dropdown renders in a portal and flips above the field when there is not enough room below.

Motion preferences

The hover highlight, checkmark draw, and chip and text transitions respect the Kinetic reduced-motion setting and the browser preference. Durations use the current tempo and the speed prop.

API Reference

Combobox

Zero-dependency searchable single or multi-chip combobox supporting both items-array mode and full compound composition.

PropTypeDefaultDescription
itemsreadonly (string | ComboboxItemOption)[]-Option strings or structured objects; required in items-array mode and optional in compound mode for render-prop ComboboxList.
multiple / value / defaultValue / onValueChangeboolean / string | readonly string[] | nullfalseSwitches between single selection and multi-value array mode with controlled or uncontrolled value state.
inputValue / defaultInputValue / onInputValueChange / filterstring / (v: string) => void / ComboboxFilterFn-Controlled or uncontrolled search query and custom filter predicate in compound mode.
open / defaultOpen / onOpenChangeboolean / (open: boolean) => void-Controlled or uncontrolled dropdown open state in compound mode.
size / showClear / speed / blurPx / invalid / disabled / name"sm" | "default" | "lg" / boolean / number / string"default" / true / 1Input height scale, clear toggle (array mode), animation speed, blur radius, validation shake, disabled state, and hidden form input name.

ComboboxInput / ComboboxTrigger / ComboboxClear / ComboboxValue

Compound blur-drift search input, standalone toggle trigger, clear button, and formatted value reader.

PropTypeDefaultDescription
showTrigger / showClear (ComboboxInput)booleantrue / falseShows the dropdown chevron button or inline clear button inside ComboboxInput.
placeholder / children (ComboboxValue)React.ReactNode | ((value: T) => React.ReactNode)"Select an option..."Fallback placeholder or render-prop receiving the active single/array value.

ComboboxContent / ComboboxList / ComboboxCollection / ComboboxItem / ComboboxEmpty

Portaled floating list with spring height resize, spring hover strip, static or render-prop items, stroke-draw checks, and flicker-free empty state.

PropTypeDefaultDescription
anchor / side / align / sideOffset / matchAnchorWidth (Content)RefObject<HTMLElement | null> / ComboboxSide / ComboboxAlign / number / booleanside="bottom" / align="start" / 6 / trueCustom anchor ref (useComboboxAnchor), floating placement, offset, and anchor width matching.
items / children (ComboboxList / ComboboxCollection)readonly T[] / ReactNode | ((item: T, index: number) => ReactNode)-Accepts static JSX children or a render function mapped over items.
value / disabled / keywords / textValue / description / onSelect (Item)string / boolean / readonly string[]-Option value, disabled flag, extra filter keywords, accessible text, subtitle, and select handler.

ComboboxGroup / ComboboxLabel / ComboboxSeparator

Auto-hiding section group (collapses when zero items match the filter), group label, and divider.

PropTypeDefaultDescription
heading (ComboboxGroup)React.ReactNode-Optional section heading rendered above grouped items.

ComboboxChips / ComboboxChip / ComboboxChipsInput / useComboboxAnchor

Multi-value chip container, pop-in removable tag chip, inline chip search input, and anchor ref hook.

PropTypeDefaultDescription
value / showRemove / removeLabel (ComboboxChip)string / boolean / stringshowRemove=trueChip value for removal, remove button visibility, and accessible remove button label.

Notes

Combobox is built on @base-ui/react: pass items on Combobox root and use Base UI render props (not asChild) when customizing Base UI elements. Toggle clear button via showClear on ComboboxInput.