React Combobox With Search
A React combobox with search in the style of Select2: type to filter, pick one or many as animated chips, group or create options, or search a server as you type.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/combobox.jsonComboboxdefaultComboboxLabels
Using it in a form? See the react-hook-form and zod recipe.
Searchable, single
Type to filter. Arrow keys move, Enter picks, Escape closes.
Shipping
Where should we send your order?
import { useState } from "react";
import { Combobox } from "@/components/sheenui/combobox/combobox";
// Package build (after the first npm release, or a packed tarball): import { Combobox } from "@sheenui/theme";
export function Example() {
const [country, setCountry] = useState<string | null>("in");
return (
<Combobox
label="Country"
placeholder="Search countries…"
options={[
{ value: "in", label: "India", icon: "🇮🇳", description: "+91" },
{ value: "us", label: "United States", icon: "🇺🇸", description: "+1" },
{ value: "gb", label: "United Kingdom", icon: "🇬🇧", description: "+44" },
{ value: "de", label: "Germany", icon: "🇩🇪", description: "+49" },
]}
value={country}
onValueChange={setCountry}
/>
);
}Files to copy
7 folders · 12 files · 4 packages
- From
theme/src/ components/combobox/components/spinner/components/status-icons/hooks/{use-direction.ts, use-latest.ts, use-media-query.ts, use-preferences.ts, use-virtual-window.ts}motion/tokens.tslib/{cn.ts, field-size.ts, glide-highlight.tsx, group-segments.ts, popup-a11y.ts, popup-motion.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/combobox.jsonRegistry item: combobox. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Multiple with chips, groups and a limit
Chips pop in and out. Backspace removes the last one; Left Arrow moves into the chips.
Your profile
Skills show on your public profile.
Pick up to 5.3/5
import { useState } from "react";
import { Combobox } from "@/components/sheenui/combobox/combobox";
// Package build (after the first npm release, or a packed tarball): import { Combobox } from "@sheenui/theme";
export function Example() {
const [picked, setPicked] = useState<string[]>(["py", "django", "react"]);
return (
<Combobox
multiple
maxSelected={5}
label="Skills"
options={[
{ value: "py", label: "Python", group: "Languages" },
{ value: "django", label: "Django", group: "Frameworks" },
{ value: "temporal", label: "Temporal", group: "Infrastructure" },
{ value: "react", label: "React", group: "Frameworks" },
{ value: "postgres", label: "PostgreSQL", group: "Infrastructure" },
]}
value={picked}
onValueChange={setPicked}
/>
);
}Creatable tags
Type something new and choose “Create …” to add it.
New issue
Label it so the right people see it.
import { Combobox, type ComboboxOption } from "@/components/sheenui/combobox/combobox";
// Package build (after the first npm release, or a packed tarball): import { Combobox, type ComboboxOption } from "@sheenui/theme";
const tags: ComboboxOption[] = [
{ value: "design", label: "design" },
{ value: "frontend", label: "frontend" },
{ value: "bug", label: "bug" },
{ value: "urgent", label: "urgent" },
];
export function Example() {
return (
<Combobox
multiple
label="Labels"
options={tags}
defaultValue={["design"]}
onCreate={(label) => ({ value: label.toLowerCase(), label })}
/>
);
}Async search
Results come from a (pretend) server as you type, with a loading state. Try “ra” or “sh”.
Invite to workspace
They get an email with a link to join.
import { Combobox } from "@/components/sheenui/combobox/combobox";
// Package build (after the first npm release, or a packed tarball): import { Combobox } from "@sheenui/theme";
export function Example() {
return (
<Combobox
multiple
label="Invite people"
placeholder="Search by name…"
loadOptions={async (query) => {
const res = await fetch(`/api/people?q=${encodeURIComponent(query)}`);
return res.json(); // [{ value, label, description?, icon? }]
}}
/>
);
}Thousands of options
Windowed above 200 options (virtualized defaults to auto): filtering runs over all 5,000, only the visible rows are in the DOM, the arrow keys and aria-activedescendant follow the active option, and group headings stay in order. Type 'Item 4999' or arrow down.
import { Combobox } from "@/components/sheenui/combobox/combobox";
// Package build (after the first npm release, or a packed tarball): import { Combobox } from "@sheenui/theme";
const options = Array.from({ length: 5000 }, (_, i) => ({
value: String(i + 1),
label: `Item ${String(i + 1).padStart(4, "0")}`,
group: i < 2500 ? "First half" : "Second half",
}));
export function Example() {
return <Combobox label="Item" options={options} virtualized />;
}Props
ComboboxLabels keys and English defaults (15)
Keyboard
Accessibility
- The ARIA combobox pattern: an input with aria-expanded and aria-controls plus a listbox of options.
- Result counts, loading, errors and the "create" option are announced politely; focus never leaves the input.
- error marks the field invalid and is linked to it; chips have remove buttons with names.
- Without a visible label, pass aria-label or aria-labelledby. Every string is translatable through the label props.
All exports on this page
Combobox— Searchable select (Select2-style): single or multiple selection with chips, groups, icons, a "create" option and async search.defaultComboboxLabels— The English ComboboxLabels used when labels is omitted; a partial labels prop is merged over it.
When to use Combobox
- Use Combobox as a Select2-style searchable select for a country or timezone picker, where the list has dozens of entries and people would rather type a few letters than scroll a long menu. Use it as an autocomplete for React and Tailwind projects when a plain select is too long to scan and people need to type to narrow the options.
- Use multiple with chips for choosing tags or assignees, with maxSelected to cap the count and Backspace to remove the last chip from the keyboard.
- Use loadOptions for a user search backed by an API; requests are debounced by debounceMs, and loading, empty and failed states with a Try again option are shown in the popup.
- Skip it when there are only a handful of fixed options. Use Select for a short list, RadioGroup for two or three visible choices, or Command for an app-wide action search.
- Pair it with Field or react-hook-form through name, ref and onBlur, Badge or Avatar as option icons, and Button for the submit step of the form around it.
Looking for Select2 in React?
Select2 is a jQuery plugin for searchable selects, tags and remote data. SheenUI's Combobox gives the same features in React without jQuery: type to filter, multiple selection as removable chips, grouped options, created options through onCreate and async search through loadOptions, built on Base UI's Combobox so the ARIA pattern is correct.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .