Skip to content

Select

import { Select } from 'yarcl';

Value: pro

const plans = [
{ value: 'free', label: 'Free' },
{ value: 'pro', label: 'Pro' },
{ value: 'enterprise', label: 'Enterprise', disabled: true },
];
<Field label="Plan">
<Select options={plans} value={plan} onValueChange={setPlan} placeholder="Choose a plan" />
</Field>

Options are data, not children: the selected label is known even while the list is closed, and the value type is inferred from options. Pass name to submit the value with a form.

Key Action
Enter Space opens the list at the selected option
moves between options, skipping disabled ones
typing jumps to a matching option, even while closed
Enter Space chooses the focused option
Esc closes without changing the value

Accepts every native <button> attribute except color, value, defaultValue and onChange.

PropTypeDefaultDescription
options requiredreadonly SelectOption<V>[]The options to choose from.
colorColorconfigconfig.defaults.colorSemantic color, from the colors config.
defaultValueV | nullnullInitial value when uncontrolled.
namestringForm field name. Renders a hidden input with the value.
onValueChange(value: V | null) => voidCalled with the chosen option's value.
placeholderReactNodeText shown when nothing is selected.
radius'size' | Radiusconfigconfig.defaults.radiusBorder radius, from the radii config, or 'size' for the radius named like the control's size.
sizeSizeconfigconfig.defaults.sizeControl size, from the sizes config.
valueV | nullControlled value. null means nothing is selected.
PropTypeDefaultDescription
label requiredstringText shown to the user. Also used for type-to-select and filtering.
value requiredVValue reported by onValueChange and submitted with forms.
disabledbooleanPrevents choosing this option.