Skip to Content
ComponentsCombobox

Combobox

A styled autocomplete/combobox built on Base UI’s Combobox primitive. Includes text input with built-in filtering, popup with items, grouped options, multi-select with chips, and built-in Floating UI positioning.

Import

import { Combobox } from "chunks-ui";

Basic Usage

const fruits = [ { value: "apple", label: "Apple" }, { value: "banana", label: "Banana" }, { value: "cherry", label: "Cherry" }, ]; <Combobox.Root items={fruits}> <div className="relative"> <Combobox.Input placeholder="Search a fruit..." /> <Combobox.Trigger /> </div> <Combobox.Portal> <Combobox.Positioner> <Combobox.Popup> <Combobox.List> {(item) => ( <Combobox.Item key={item.value} value={item.value}> {item.label} <Combobox.ItemIndicator /> </Combobox.Item> )} </Combobox.List> <Combobox.Empty>No results found.</Combobox.Empty> </Combobox.Popup> </Combobox.Positioner> </Combobox.Portal> </Combobox.Root>

With Clear Button

<Combobox.Root items={fruits}> <div className="relative"> <Combobox.Input placeholder="Search a fruit..." /> <Combobox.Clear /> <Combobox.Trigger /> </div> <Combobox.Portal> <Combobox.Positioner> <Combobox.Popup> <Combobox.List> {(item) => ( <Combobox.Item key={item.value} value={item.value}> {item.label} <Combobox.ItemIndicator /> </Combobox.Item> )} </Combobox.List> <Combobox.Empty>No results found.</Combobox.Empty> </Combobox.Popup> </Combobox.Positioner> </Combobox.Portal> </Combobox.Root>

Grouped Options

<Combobox.Root items={colors}> <div className="relative"> <Combobox.Input placeholder="Pick a color..." /> <Combobox.Trigger /> </div> <Combobox.Portal> <Combobox.Positioner> <Combobox.Popup> <Combobox.Group> <Combobox.GroupLabel>Warm</Combobox.GroupLabel> <Combobox.List> {(item) => ( <Combobox.Item key={item.value} value={item.value}> {item.label} <Combobox.ItemIndicator /> </Combobox.Item> )} </Combobox.List> </Combobox.Group> <Combobox.Empty>No results found.</Combobox.Empty> </Combobox.Popup> </Combobox.Positioner> </Combobox.Portal> </Combobox.Root>

Multi-Select with Chips

function MultiSelectCombobox() { const [value, setValue] = useState<string[]>([]); return ( <Combobox.Root multiple items={frameworks} value={value} onValueChange={setValue}> <Combobox.Control> <Combobox.Chips> {value.map((v) => { const item = frameworks.find((f) => f.value === v); return ( <Combobox.Chip key={v}> {item?.label ?? v} <Combobox.ChipRemove /> </Combobox.Chip> ); })} </Combobox.Chips> <Combobox.Input className="h-7 min-w-20 flex-1 border-0 bg-transparent px-0 focus-visible:outline-none" placeholder="Select frameworks..." /> <Combobox.Clear /> <Combobox.Trigger /> </Combobox.Control> <Combobox.Portal> <Combobox.Positioner> <Combobox.Popup> <Combobox.List> {(item) => ( <Combobox.Item key={item.value} value={item.value}> {item.label} <Combobox.ItemIndicator /> </Combobox.Item> )} </Combobox.List> <Combobox.Empty>No results found.</Combobox.Empty> </Combobox.Popup> </Combobox.Positioner> </Combobox.Portal> </Combobox.Root> ); }

Controlled

function ControlledCombobox() { const [value, setValue] = useState(null); const items = [ { value: "active", label: "Active" }, { value: "inactive", label: "Inactive" }, { value: "pending", label: "Pending" }, ]; return ( <Combobox.Root items={items} value={value} onValueChange={setValue}> <div className="relative"> <Combobox.Input placeholder="Select status..." /> <Combobox.Clear /> <Combobox.Trigger /> </div> <Combobox.Portal> <Combobox.Positioner> <Combobox.Popup> <Combobox.List> {(item) => ( <Combobox.Item key={item.value} value={item.value}> {item.label} <Combobox.ItemIndicator /> </Combobox.Item> )} </Combobox.List> <Combobox.Empty>No results found.</Combobox.Empty> </Combobox.Popup> </Combobox.Positioner> </Combobox.Portal> </Combobox.Root> ); }

Compound Parts

PartDescription
Combobox.RootState container. Manages open/close, filtering, and selected value(s).
Combobox.ControlBordered wrapper for multi-select (chips + input). Uses has-[:focus-visible] for focus ring.
Combobox.InputText input with built-in filtering.
Combobox.TriggerButton that toggles the popup. Renders a default chevron icon.
Combobox.IconChevron icon, usable standalone outside the trigger.
Combobox.PortalRenders the popup in a portal.
Combobox.PositionerHandles Floating UI positioning.
Combobox.PopupThe dropdown panel containing items.
Combobox.ListList container. Uses render-prop children.
Combobox.ItemAn individual selectable option.
Combobox.ItemIndicatorCheckmark shown for the selected item.
Combobox.EmptyMessage displayed when no items match the filter.
Combobox.ClearButton that clears the current value. Renders a default X icon.
Combobox.GroupGroups related items together.
Combobox.GroupLabelLabel for a group of items.
Combobox.ChipsContainer for selected chips in multi-select mode. Uses render-prop children.
Combobox.ChipA styled chip representing a selected value.
Combobox.ChipRemoveButton to remove a chip. Renders a default X icon.
Combobox.ValueDisplays the selected value.
Combobox.StatusAccessible status announcements for screen readers.

Combobox.Root Props

PropTypeDefaultDescription
itemsArray<{ value: string; label: string }>The items to display in the list
valuestring | string[]Controlled selected value
defaultValuestring | string[]Initial value (uncontrolled)
onValueChange(value: string | string[]) => voidCalled when selection changes
multiplebooleanfalseEnable multi-select mode
openbooleanControlled open state
onOpenChange(open: boolean) => voidCalled when open state changes

Combobox.Input Props

PropTypeDefaultDescription
placeholderstringPlaceholder text
disabledbooleanfalseDisable the input
classNamestringAdditional CSS classes
Last updated on