Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

Select

Free2.6 KB gzipped

Styled 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

tsx
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: ""

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

tsx
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

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

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

tsx
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

Select props
PropTypeDefault
size

Control height and text size. Defaults to the surrounding Field's size, then md.

"sm""md""lg"—
variant

Visual style.

"outline""filled"—
radius

Corner rounding. Defaults to the shared text-field radius (--field-radius).

"none""xs""sm""md""lg""xl""2xl""pill"—
invalid

Show danger styling and set aria-invalid. Inherited from a surrounding Field. Pair with visible error text, since color alone is not enough.

boolean—
readOnly

Shows the value without allowing changes (<select> has no native read-only): the list doesn't open and aria-readonly is set. Inherited from a surrounding Field.

boolean—
placeholder

Prompt shown while no value is chosen. Renders a disabled first option with an empty value that is hidden from the open list. Combine with required to make native validation reject the empty choice. Ignored when multiple is set.

string—
options

Shortcut for the choices. Takes precedence over children. Entries with options render as <optgroup>.

SelectItem[]—
children

<option> and <optgroup> elements, used when options is not set.

ReactNode—
startIcon

Decorative icon at the inline start (hidden from assistive technology). Not shown in list mode (multiple or htmlSize > 1).

ReactNode—
multiple

Allow choosing several options. Renders an always-open list box with no chevron.

boolean—
htmlSize

Native size attribute: the number of visible rows in list mode. Named htmlSize so it doesn't clash with size.

number—
value

Controlled value (string[] when multiple).

SelectValue—
defaultValue

Initial value when uncontrolled. Defaults to "" (or [] when multiple).

SelectValue—
onValueChange

Called with the new value (string[] when multiple) whenever the choice changes.

(value: SelectValue) => void—
fullWidth

Stretch to the full inline size of the container.

boolean—
className

Class for the outer wrapper. Use selectClassName to target the <select> itself.

string—
selectClassName

Class for the native <select> element.

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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Keyboard
KeyAction
Arrow UpArrow DownChanges the option (the browser's native select).
SpaceAlt+Arrow DownOpens the option list, depending on the browser.
TypingJumps to the option that starts with the typed characters.

Roles and states

Roles and states
ElementRoleStates and properties
<select>comboboxaria-invalid, aria-describedby → hint and error
Optionsoption / group<option> and <optgroup>

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)