ValyroUI English version

Combobox

Поиск и выбор. Бесплатно, MIT · Формы и ввод › Выбор из списка

Установка

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';

Пропсы

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.

Составные части

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

Похожие компоненты

  • Select — Выбор из списка
  • Multi Select — Множественный выбор
  • Listbox — Список вариантов на странице: один или несколько, диапазоны с Shift
  • Chip Group — Группа чипов с иконками: один или несколько вариантов
  • Checkbox Tree — Дерево с чекбоксами: каскад, частичная отметка, клавиатура
  • Text Input — Текстовые поля
  • Textarea — Многострочный ввод
  • Search Input — Поисковая строка
  • Mentions Input — Текст с @упоминаниями и #тегами, асинхронные подсказки
  • Tags Input — Ввод тегов
  • Checkbox — Флажки
  • Checkbox Group — Флажки с общей подписью, подсказкой, ошибкой и обязательностью

Назад: Multi Select · Далее: Listbox · Весь раздел «Формы и ввод»