YuhuanStudioYunUIDocs
Forms & Inputs

Combobox

Searchable, optionally creatable combobox — type to filter, Enter to pick or create.

A searchable, optionally creatable combobox. Type to filter the options by label or value, press Enter to pick the top match — and, when allowCustom is on (the default), to create a brand-new value that isn't in the list. It's controlled: pass value and onChange. For a fixed list without free text see CustomSelect; for the Radix-based listbox see Select.

Import

tsx
1import { Combobox } from "@yuhuanowo/yunui";

Usage

Combobox is controlled — wire value and onChange to state:

tsx
1const [value, setValue] = useState("next");
2 
3<Combobox
4 value={value}
5 onChange={setValue}
6 placeholder="Pick or type a framework…"
7 options={[
8 { value: "next", label: "Next.js", description: "React framework" },
9 { value: "remix", label: "Remix", description: "Full-stack web" },
10 { value: "astro", label: "Astro", description: "Content-first" },
11 { value: "svelte", label: "SvelteKit", description: "Compiler-based" },
12 ]}
13/>

Example

Searchable & creatable

A clear (×) button appears once a value is set — the demo above shows it on the right. Pass clearable={false} to suppress it when the field must always hold a value.

Props

PropTypeDefaultDescription
allowCustombooleantrueAllow entering a value not in `options` (creatable).
classNamestring
clearablebooleantrueShow a clear (×) action for the current value.
creatableFilter((input: string) => boolean)When set, the "create new" row only appears for inputs passing this test.
creatableIconReactNodeGlyph shown on the "create new" row (default `+`).
creatableTextstringLabel template for the "create new" row; `{value}` is replaced with the typed text.
disabledbooleanfalseDisable interaction and dim the control.
labels{ clear?: string; toggle?: string; } | undefinedAccessible names for the clear / toggle affordances. The library ships no copy of its own; the English defaults only keep it usable untranslated.
onChange*(value: string) => voidCalled with the chosen (or newly created) value.
options*ComboboxOption[]The selectable options.
placeholderstringPlaceholder for the input (falls back to i18n default).
value*stringCurrently selected value (controlled).

On this page