ValyroUI Русская версия

Combobox

Searchable select. Free, MIT · Forms and input › Selects

Editable combobox with list autocomplete. Props not listed go to the <input>; name submits the value.

Installation

npx valyro-cli@latest add combobox
npx shadcn@latest add https://valyro.xyz/r/combobox.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { Combobox } from 'valyro-ui';

Props

PropTypeDefault
optionsSelectItem[]Suggestions, flat or in labelled groups; filtered by the typed text unless filter={false}. Or compose them as children: Combobox.Item, Combobox.Group, Combobox.Empty.
childrenReactNodeThe compound form instead of options: Combobox.Item, Combobox.Group and Combobox.Empty elements.
valuestringSelected option value (or the typed text with allowCustomValue); empty string means none.
defaultValuestringInitial value when uncontrolled.
onValueChange(value: string) => voidCalled with the new value when it changes.
inputValuestringText in the input. Control it together with filter={false} to load options asynchronously.
defaultInputValuestringInitial inputValue when uncontrolled.
onInputValueChange(text: string) => voidCalled with the text whenever the input changes (typing, picking an option, clearing).
openbooleanControlled open; use with onOpenChange.
defaultOpenbooleanInitial open when uncontrolled.
onOpenChange(open: boolean) => voidCalled with the new open when it changes.
filterfalse | ((option: SelectOption, query: string) => boolean)Custom matcher, or false when options are already filtered (e.g. by a server). Default: the label contains the text, ignoring case and accents for the ThemeProvider locale ("e" finds "é", as React Aria's useFilter).
loadingbooleanfalseShows a spinner in the field, sets aria-busy, and replaces the empty state with a loading message.
emptyTextReactNodeShown in the popover when no option matches (unless allowCustomValue offers the typed text). Or Combobox.Empty.
labelsPartial<ComboboxLabels>Overrides for the built-in English text; keys left out keep their defaults.
allowCustomValuebooleanfalseTyped text that matches no option is kept as the value on Enter / blur.
size'sm' | 'md' | 'lg''md'Field height and text size.
invalidbooleanfalseError border and aria-invalid on the input (an explicit aria-invalid wins).
leftIconReactNodeIcon inside the field, before the text.

Compound parts

Combobox.Item (ComboboxItem), Combobox.Group (ComboboxGroup), Combobox.Empty (ComboboxEmpty)

Related components

Previous: Multi Select · Next: Listbox · All Forms and input