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

Select

Pick one option from a list. Free, MIT · Forms and input › Selects

Select-only combobox: a field-styled trigger that opens a listbox. Props not listed go to the trigger button.

Installation

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

Props

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).

Compound parts

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

Related components

Previous: Tags Input · Next: Multi Select · All Forms and input