Loading component…
Loading component…
Pick one or many from a searchable, grouped list – chips with avatars, highlighted matches, create-on-the-fly and full keyboard support
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Combobox from ./combobox.
import { Combobox, type ComboboxOption } from "@/components/ui/combobox";
const people: ComboboxOption[] = [
{ value: "maya", label: "Maya Chen", hint: "Product Designer", avatar: true, group: "Design" },
{ value: "sara", label: "Sara Okafor", hint: "Staff Engineer", avatar: "/avatars/sara.jpg", group: "Engineering" },
{ value: "elif", label: "Elif Yilmaz", hint: "Head of Product", avatar: true, group: "Product" },
];
export function Reviewers() {
const [reviewers, setReviewers] = useState<string[]>(["maya"]);
return (
<Combobox
label="Reviewers"
options={people}
value={reviewers}
onChange={setReviewers}
placeholder="Add reviewers…"
maxVisibleTags={4}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| options | { value, label, hint?, avatar?, color?, icon?, group?, keywords? }[] | The list. avatar is an image URL or true for initials; options with the same group are listed under one title | |
| multiple | boolean | true | Pick many (chips) or one – one closes the list after picking |
| value | string[] | Controlled values (also for single choice, with at most one entry) | |
| defaultValue | string[] | [] | Starting values when uncontrolled |
| onChange | (value: string[], options: ComboboxOption[]) => void | Called on every pick, removal or creation | |
| placeholder | string | "Search…" | Shown while nothing is picked |
| creatable | boolean | false | Offer a create row when no option matches the typed text exactly |
| onCreate | (text: string) => ComboboxOption \| void | Builds the new option – defaults to { value: text, label: text } | |
| createLabel | (text: string) => string | Create “…” | Text of the create row, e.g. Invite “…” |
| maxVisibleTags | number | Show at most this many chips, the rest as a "+3" chip | |
| label | string | Visible label above the field (also names the list) | |
| defaultOpen | boolean | false | Open the list right away |
| emptyText | string | "No results" | Shown when nothing matches |
| className | string | Extra class on the root |
The list is as wide as the field, so it always fits the screen
Chips wrap onto new lines and long names truncate – works down to 320px
Touch screens get 44px rows, bigger chip buttons and 16px input text (no iOS zoom)
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"