ValyroUI English version

Select

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

Установка

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

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

Пропсы

PropTypeDefault
optionsSelectItem[]Options to pick from, flat or in labelled groups. Or compose them as children: Select.Item, Select.Group.
childrenReactNodeThe compound form instead of options: Select.Item and Select.Group elements.
valuestringSelected option value; an empty string means nothing is selected.
defaultValuestringInitial value when uncontrolled.
onValueChange(value: string) => voidCalled with the new value when it changes.
openbooleanControlled open; use with onOpenChange.
defaultOpenbooleanInitial open when uncontrolled.
onOpenChange(open: boolean) => voidCalled with the new open when it changes.
placeholderstring'Select…'Trigger text while nothing is selected.
emptyTextReactNode'No options'Shown in the popover when options is empty.
size'sm' | 'md' | 'lg''md'Trigger height and text size.
invalidbooleanfalseError border and aria-invalid on the trigger (an explicit aria-invalid wins).
namestringSubmits the value with the surrounding form (a hidden input, or the native select's own value).
nativebooleanfalseRenders a native <select> in the same field look: the phone's own wheel or sheet, the browser's form validation (required) and autofill (autoComplete). ref and the other props then go to the <select>; option icons and descriptions are not shown in its list.
requiredbooleanA value is required: aria-required, and the surrounding form does not submit without one.
autoCompletestringAutofill hint of the native select, e.g. country (with native).

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

Select.Item (SelectItemPart), Select.Group (SelectGroupPart)

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

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

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