Combobox
A value chosen from a filtered list, such as countries, species or members, with optional multiple selection shown as chips: Base UI's Combobox, inside a Field. Under about 15 options, use Select.
import { Combobox } from '@fairgarden/design/forms/combobox'
Options are { value, label } objects, or titled groups. The box is the field box, with the ring on any focus; focus stays in the input while the arrow keys highlight rows. Label it with <FieldLabel nativeLabel={false}>. When nothing matches, the empty row keeps what the user typed ("No matches for 'egrit'") instead of closing; while suggestions load it reads "Searching…"; a fetch failure shows the danger glyph and a message.
Single, multiple and states
Single, multiple and states
The chosen item's text fills the input and a ✓ marks it in the list. multiple turns choices into removable chips inside the box, which grows and never scrolls sideways; Backspace in an empty input focuses the last chip and a second Backspace removes it. onCreate adds the "+ Add '…'" row when nothing matches exactly. Matches are marked by --font-weight-7, never color.
Primary and secondary
Primary and secondary
primary sets the box, value, icons and chips; secondary is unused at rest and becomes the danger scale while invalid.
On grounds
On paper and forest
The box and its chips follow their ground; the popup renders in a portal as the white scope.
paper
forest
Outline morph
On by default: the box's focus ring, which shows on any focus, grows into the popup's frame as it opens and shrinks back onto the ring as it closes. Explicit opens morph (a click, the chevron, the arrow keys), and so does the first open after focus arrives, even when typing caused it. After that, opens and closes caused by typing are instant, so the list keeps up with the keys, and a list that resizes as results filter does so on its own. Typing is never delayed. morph={false} opens and closes the popup at once; see Outline Morph.
API Reference
A Base UI Combobox inside a Field (label it with
<FieldLabel nativeLabel={false}>). Focus stays in the input while the
arrow keys highlight rows; Backspace in an empty input focuses the last
chip, and a second Backspace removes it.
| Prop | Type | Description |
|---|---|---|
aria-label | | Names the input when no visible label exists. Prefer a |
defaultValue | | The initial choice, uncontrolled. |
value | | The chosen option (or options), controlled. |
onValueChange | | |
clearLabel | | The clear בs accessible name. Default “Clear”. |
createText | | The add row’s words. Default “Add ‘[query]'". |
emptyText | | The empty row. Default “No matches for ‘[query]'". Keep what the user typed. |
error | | A fetch failure, shown with the danger glyph instead of silently closing: “Couldn’t load suggestions. Keep typing or try again.” |
icon | | A leading icon in the box, such as |
items | | The options, or titled groups. Base UI filters them as the user types. |
loading | | Shows the loading row (“Searching…") while suggestions load. |
loadingText | | The loading row’s words. Default “Searching…". |
morph | | The outline morph: the box’s focus ring grows into the popup’s frame as
it opens and shrinks back onto the ring as it closes. Opens you ask for
(a click, the chevron, the arrow keys) and the first open after focus
arrives morph; later opens and closes caused by typing are instant.
Instant under reduced motion; off in forced colors and print, and
wherever |
multiple | |
|
onCreate | | Adds the creatable row “+ Add ‘[query]'” when nothing matches exactly
(flat lists only). Called with the query; add the option to |
placeholder | | The input’s placeholder, ending in “…"; never the label. |
plate | | The box face becomes a nested |
primary | | Primary Radix scale: edge, value, icons, chips and focus ring. Never defaulted [D133]. |
removeLabel | | A chip בs accessible name. Default “Remove [label]". |
secondary | | Secondary Radix scale. Unused at rest; the danger scale while invalid. |
triggerLabel | | The chevron’s accessible name. Default “Show options”. |
className | | Class names for the box, added after the module’s own. |
ComboboxOption
One option: a string value and the words the list and the input show.
type ComboboxOption = { value: string; label: string; disabled?: boolean }ComboboxOptionGroup
A titled group of options.
type ComboboxOptionGroup = {
/** The group label, in `type-label` caps. */
label: string;
items: ComboboxOption[];
}ComboboxProps
Props for Combobox: Base UI Combobox.Root props plus the options, rows and color axes.
type ComboboxProps<Multiple extends boolean | undefined = false> = {
/** The options, or titled groups. Base UI filters them as the user types. */
items: ComboboxItems;
/** `true` chooses several values, shown as removable chips in the box. Default `false`. */
multiple?: boolean | undefined;
/** The chosen option (or options), controlled. */
value?: ComboboxOption[] | ComboboxOption | null;
/** The initial choice, uncontrolled. */
defaultValue?: ComboboxOption[] | ComboboxOption | null;
onValueChange?: (
value: ComboboxOption[] | ComboboxOption | null,
eventDetails: ComboboxRoot.ChangeEventDetails,
) => void;
/** The input's placeholder, ending in "…"; never the label. */
placeholder?: string;
/** A leading icon in the box, such as `search` (inline tier). */
icon?:
| 'search'
| 'arrow_forward'
| 'arrow_upward'
| 'expand_more'
| 'close'
| 'remove'
| 'add'
| 'check'
| 'circle'
| 'chevron_right'
| 'chevron_left'
| 'menu'
| 'more_horiz'
| 'more_vert'
| 'play_arrow'
| 'pause'
| 'download'
| 'zoom_in'
| 'zoom_out'
| 'recenter'
| 'help'
| 'mail'
| 'content_copy'
| 'link'
| 'open_in_new'
| 'restart_alt'
| 'description'
| 'widgets'
| 'deployed_code'
| 'format_h2'
| 'format_h3';
/** The empty row. Default "No matches for '[query]'". Keep what the user typed. */
emptyText?: (query: string) => React.ReactNode;
/** Shows the loading row ("Searching…") while suggestions load. */
loading?: boolean;
/** The loading row's words. Default "Searching…". */
loadingText?: React.ReactNode;
/**
* A fetch failure, shown with the danger glyph instead of silently
* closing: "Couldn't load suggestions. Keep typing or try again."
*/
error?: React.ReactNode;
/**
* Adds the creatable row "+ Add '[query]'" when nothing matches exactly
* (flat lists only). Called with the query; add the option to `items`
* and select it through `value`.
*/
onCreate?: (query: string) => void;
/** The add row's words. Default "Add '[query]'". */
createText?: (query: string) => React.ReactNode;
/** The clear ×'s accessible name. Default "Clear". */
clearLabel?: string;
/** The chevron's accessible name. Default "Show options". */
triggerLabel?: string;
/** A chip ×'s accessible name. Default "Remove [label]". */
removeLabel?: (label: string) => string;
/** Names the input when no visible label exists. Prefer a `FieldLabel`. */
'aria-label'?: string;
/** Class names for the box, added after the module's own. */
className?: string;
/** The box face becomes a nested `white` scope; patterned grounds only (§10.1). */
plate?: boolean;
/** Primary Radix scale: edge, value, icons, chips and focus ring. Never defaulted [D133]. */
primary?:
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'ruby'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
/** Secondary Radix scale. Unused at rest; the danger scale while invalid. */
secondary?:
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'ruby'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
/**
* The outline morph: the box's focus ring grows into the popup's frame as
* it opens and shrinks back onto the ring as it closes. Opens you ask for
* (a click, the chevron, the arrow keys) and the first open after focus
* arrives morph; later opens and closes caused by typing are instant.
* Instant under reduced motion; off in forced colors and print, and
* wherever `--fgd-outline-morph: none` applies. Default `true`; `false`
* opens and closes the popup at once.
*/
morph?: boolean;
}Specification: DESIGN-SYSTEM.md §10.6 (combobox and autocomplete) and §10.11 (the removable chip).