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<Combobox4 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
| Prop | Type | Default | Description |
|---|---|---|---|
| allowCustom | boolean | true | Allow entering a value not in `options` (creatable). |
| className | string | — | |
| clearable | boolean | true | Show a clear (×) action for the current value. |
| creatableFilter | ((input: string) => boolean) | — | When set, the "create new" row only appears for inputs passing this test. |
| creatableIcon | ReactNode | — | Glyph shown on the "create new" row (default `+`). |
| creatableText | string | — | Label template for the "create new" row; `{value}` is replaced with the typed text. |
| disabled | boolean | false | Disable interaction and dim the control. |
| labels | { clear?: string; toggle?: string; } | undefined | — | Accessible 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) => void | — | Called with the chosen (or newly created) value. |
| options* | ComboboxOption[] | — | The selectable options. |
| placeholder | string | — | Placeholder for the input (falls back to i18n default). |
| value* | string | — | Currently selected value (controlled). |