Components
Combobox
Searchable select with single or multiple choice, item icons, counts and a footer for actions.
import { Combobox } from "@openperf/deft";
<Combobox.Root items={["api", "docs", "web", "worker"]}>
<Combobox.Trigger>
<Combobox.Value placeholder="Select a project" />
</Combobox.Trigger>
<Combobox.Content>
<Combobox.Search />
<Combobox.Empty>No projects found</Combobox.Empty>
<Combobox.List>
{(project: string) => (
<Combobox.Item key={project} value={project}>
{project}
</Combobox.Item>
)}
</Combobox.List>
</Combobox.Content>
</Combobox.Root>;When to use
| Need | Component |
|---|---|
| List long enough to search, or several values | Combobox |
| One value from a short list, no search | Select |
| Commands that run on click, not a stored value | Menu |
Anatomy
<Combobox.Root>
<Combobox.Trigger>
<Combobox.Value /> {/* or your own text */}
</Combobox.Trigger>
{/* portal, positioner and popup */}
<Combobox.Content>
<Combobox.Search />
<Combobox.Empty /> {/* shown when nothing matches */}
<Combobox.List>
{/* optional grouping */}
<Combobox.Group>
<Combobox.GroupLabel />
<Combobox.Item />
</Combobox.Group>
</Combobox.List>
<Combobox.Footer /> {/* optional actions on the whole selection */}
</Combobox.Content>
</Combobox.Root>Pass the options to Combobox.Root as items and give Combobox.List a function that renders one item: the list then shows only the items matching the search, and Combobox.Empty, which requires items, shows its children when none match. Combobox.Trigger adds the chevron but does not render the value.
| Part | Behaviour |
|---|---|
Combobox.Content | 280px wide, 4px from the trigger; change the width with className |
Combobox.List | Scrolls beyond 288px |
Combobox.Item | Label is cut with an ellipsis when it does not fit |
Multiple selection
multiple on the root makes the value an array and keeps the popup open while picking. Mark items with indicator="checkbox" and build the trigger text from the value yourself. Object items need itemToStringLabel unless they have the { value, label } shape.
API
Combobox.Root, Combobox.Value, Combobox.Group and the other Base UI parts are exported unchanged. On the root, the props used most are items, value, defaultValue, onValueChange, multiple and itemToStringLabel.
Combobox.Trigger
Prop
Type
Combobox.Content
Prop
Type
Combobox.Search
The field has no visible label: set aria-label. The default placeholder is a Lingui message, so render the combobox under the root providers.
Prop
Type
Combobox.Item
Prop
Type