Combobox
"use client";
import { Combobox, Field } from "@cherry-design-system/react";
export function Framework() {
return (
<Field label="Framework">
<Combobox options={["Next.js", "Remix", "Astro"]} placeholder="Select a framework" />
</Field>
);
}A text input with a filterable listbox, following the ARIA combobox pattern. The list is a native popover placed with CSS anchor positioning. Use it for long lists such as countries or frameworks. Use Select for a short, fixed list.
Examples
Value and label objects
Plain strings are both value and label. Pass { value, label, disabled } objects to separate them or disable an option.
"use client";
import { useState } from "react";
import { Combobox, Field, type ComboboxOption } from "@cherry-design-system/react";
const countries: ComboboxOption[] = [
{ value: "al", label: "Albania" },
{ value: "de", label: "Germany" },
{ value: "it", label: "Italy", disabled: true },
];
export function Country() {
const [country, setCountry] = useState<string | null>(null);
return (
<Field label="Country">
<Combobox
options={countries}
value={country}
onValueChange={setCountry}
placeholder="Search countries"
/>
</Field>
);
}Empty state
"use client";
import { Combobox, Field } from "@cherry-design-system/react";
export function Language() {
return (
<Field label="Language">
<Combobox
options={["English", "German", "Albanian"]}
emptyMessage="No languages found"
emptyHint="Try another spelling."
/>
</Field>
);
}Custom filter
The default matcher is a case-insensitive "contains". Pass filter to change it.
"use client";
import { Combobox, Field } from "@cherry-design-system/react";
export function StartsWith() {
return (
<Field label="City">
<Combobox
options={["Berlin", "Bern", "Tirana"]}
filter={(option, query) => option.label.toLowerCase().startsWith(query.toLowerCase())}
/>
</Field>
);
}Translated labels
"use client";
import { Combobox, Field } from "@cherry-design-system/react";
export function Marco() {
return (
<Field label="Marco">
<Combobox
options={["Next.js", "Remix", "Astro"]}
emptyMessage="Sin resultados"
toggleLabel="Mostrar opciones"
resultsLabel={(count) => (count === 1 ? "1 resultado" : `${count} resultados`)}
/>
</Field>
);
}Properties
The choices; plain strings are both value and label. ComboboxOption is { value: string; label: string; disabled?: boolean }.
Controlled selected value (null means none).
Initial value when uncontrolled.
Called when the selected value changes.
Called with the typed text on every keystroke.
Custom matcher. Defaults to a case-insensitive "contains".
Control size. Defaults to "md".
Error state; set automatically inside a <Field error>.
Shown when nothing matches. Defaults to "No results found".
Second line under emptyMessage.
Live-region text for the match count (translate here). Defaults to "1 result" / "{count} results".
Name of the chevron button. Defaults to "Show options".
Class for the outer wrapper (className goes to the <input>).
The ref and native <input> attributes (except value, defaultValue, onChange, type and list) go to the <input>.
Styling
Root class cherry-combobox with data-size (sm, md, lg) and states data-open, data-invalid, data-disabled. Options use data-active, aria-selected and aria-disabled. Parts: cherry-combobox__input, __trigger, __popover, __listbox, __option, __option-label, __check, __empty, __empty-title, __empty-hint.
Reads the field tokens plus --cherry-bg-elevated, --cherry-elevation-lg and --cherry-ghost-hover for the list.
Accessibility
Combobox and listbox pattern: Up and Down highlight options through aria-activedescendant, Enter selects, Escape closes. The match count is announced through a live region (resultsLabel). Label it with Field.