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

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

Usage

Combobox is controlled — wire value and onChange to state:

const [value, setValue] = useState("next");

<Combobox
  value={value}
  onChange={setValue}
  placeholder="Pick or type a framework…"
  options={[
    { value: "next", label: "Next.js", description: "React framework" },
    { value: "remix", label: "Remix", description: "Full-stack web" },
    { value: "astro", label: "Astro", description: "Content-first" },
    { value: "svelte", label: "SvelteKit", description: "Compiler-based" },
  ]}
/>

Example

Searchable & creatable

Props

PropTypeDefaultDescription
allowCustombooleantrueAllow entering a value not in `options` (creatable).
classNamestring
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.
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