Forms
Select
Free2.6 KB gzippedStyled native <select>. Keeps the browser's keyboard model, mobile pickers, autofill, and form submission, and matches the Input and Textarea look. Works standalone or inside a Field, which wires its id, label, description, error, required, disabled, and size.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Arrow Up, Arrow Down, Space and 1 more · Full report
Import
import { Select } from "@vjdesigns/vjdesigns-ui";
Importing only Select adds about 2.6 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
A styled native <select>: familiar on every device, including the phone's own picker.
Value: ""
import { useState } from "react";
import { Field, Select, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
const [country, setCountry] = useState("");
return (
<Stack gap={3} style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Country">
<Select
placeholder="Choose a country"
value={country}
onValueChange={(value) => setCountry(String(value))}
options={[
{ value: "ca", label: "Canada" },
{ value: "mx", label: "Mexico" },
{ value: "us", label: "United States" },
]}
/>
</Field>
<Text size="sm" tone="muted">
Value: <code>{JSON.stringify(country)}</code>
</Text>
</Stack>
);
}
Groups
Pass { label, options } objects to group options.
import { Field, Select } from "@vjdesigns/vjdesigns-ui";
export function Groups() {
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Plan">
<Select
defaultValue="pro-monthly"
options={[
{
label: "Core",
options: [{ value: "core", label: "Core (free)" }],
},
{
label: "Pro",
options: [
{ value: "pro-monthly", label: "Pro, billed monthly" },
{ value: "pro-yearly", label: "Pro, billed yearly" },
],
},
]}
/>
</Field>
</div>
);
}
Sizes and states
import { Select, Stack } from "@vjdesigns/vjdesigns-ui";
export function SizesAndStates() {
const options = [
{ value: "a", label: "Option A" },
{ value: "b", label: "Option B" },
];
return (
<Stack gap={3} style={{ width: "100%", maxWidth: "20rem" }}>
<Select aria-label="Small select" size="sm" options={options} />
<Select aria-label="Filled select" variant="filled" options={options} />
<Select aria-label="Disabled select" disabled options={options} />
<Select aria-label="Invalid select" invalid options={options} />
</Stack>
);
}
Accessibility
Select is a native <select>, so the keyboard, screen readers and phone pickers work exactly as people expect. A placeholder with required makes the browser reject the empty choice, and Field connects the label and error.
Choose the country you ship to.
import { useState } from "react";
import { Field, Select } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
const [country, setCountry] = useState("");
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="Country" required error={country ? undefined : "Choose the country you ship to."}>
<Select
placeholder="Choose a country"
required
value={country}
onValueChange={(value) => setCountry(String(value))}
options={[
{ value: "ca", label: "Canada" },
{ value: "mx", label: "Mexico" },
{ value: "us", label: "United States" },
]}
fullWidth
/>
</Field>
</div>
);
}
Translated
In a right-to-left locale such as Arabic, the field mirrors: the chevron moves to the left and text aligns right. Option labels are your own text.
import { Field, Select, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
export function Translated() {
return (
<LocaleProvider locale="ar" messages={ar}>
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Field label="البلد">
<Select
defaultValue="eg"
options={[
{ value: "eg", label: "مصر" },
{ value: "ma", label: "المغرب" },
{ value: "ae", label: "الإمارات" },
]}
fullWidth
/>
</Field>
</div>
</LocaleProvider>
);
}
API reference
Select
| Prop | Type | Default |
|---|---|---|
sizeControl height and text size. Defaults to the surrounding Field's size, then | "sm""md""lg" | — |
variantVisual style. | "outline""filled" | — |
radiusCorner rounding. Defaults to the shared text-field radius ( | "none""xs""sm""md""lg""xl""2xl""pill" | — |
invalidShow danger styling and set | boolean | — |
readOnlyShows the value without allowing changes ( | boolean | — |
placeholderPrompt shown while no value is chosen. Renders a disabled first option with an empty value that is hidden from the open list. Combine with | string | — |
optionsShortcut for the choices. Takes precedence over | SelectItem[] | — |
children
| ReactNode | — |
startIconDecorative icon at the inline start (hidden from assistive technology). Not shown in list mode ( | ReactNode | — |
multipleAllow choosing several options. Renders an always-open list box with no chevron. | boolean | — |
htmlSizeNative | number | — |
valueControlled value ( | SelectValue | — |
defaultValueInitial value when uncontrolled. Defaults to | SelectValue | — |
onValueChangeCalled with the new value ( | (value: SelectValue) => void | — |
fullWidthStretch to the full inline size of the container. | boolean | — |
classNameClass for the outer wrapper. Use | string | — |
selectClassNameClass for the native | string | — |
Also accepts native <select> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Select targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Arrow UpArrow Down | Changes the option (the browser's native select). |
| SpaceAlt+Arrow Down | Opens the option list, depending on the browser. |
| Typing | Jumps to the option that starts with the typed characters. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
<select> | combobox | aria-invalid, aria-describedby → hint and error |
| Options | option / group | <option> and <optgroup> |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |