Skip to content

Components / Select

Select

A square, monospaced single-choice popup powered by Radix. Choose from grouped options with keyboard navigation, typeahead and a placeholder.

Prefer Native Select when native browser behavior suffices, especially for mobile pickers or multiple selection. Select has no search or multiselect.

Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.

Usage playground

Choose a single value from labeled groups. Blueberry is unavailable. Try arrows, typeahead or a disabled field; clear returns to the placeholder. The invalid preview is explicit feedback, not automatic validation.

Selected: none

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator } from "@/components/ui/yads-select";

const fieldStyle = { display: 'grid', gap: '0.75rem', width: '100%', maxWidth: '24rem' } as const;

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/select#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Documentation samples use basic Tailwind utilities for layout. Install each YADS component imported by the sample.

Run this revision-pinned command in a shadcn-configured project. It installs yads-select, its scoped CSS, @radix-ui/[email protected] and JetBrains Mono 5.3.0. Import from @/components/ui/yads-select (adjust the alias to your project). No Tailwind, reset, global stylesheet, theme provider or other YADS primitive is required.

Copy sample includes the full React module, client boundary and any recipe CSS even when collapsed. All examples use ordinary labels and buttons and work without site styles.

Form submission and reset

Uncontrolled defaultValue with name and required. Radix renders a visually hidden native select inside a form for FormData and browser constraints. Reset restores the initial mounted value in Radix 2.4.1. For controlled usage, accept onValueChange or explicitly restore your state in onReset. The demo reports locally without sending a request.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator } from "@/components/ui/yads-select";

const fieldStyle = { display: 'grid', gap: '0.75rem', width: '100%', maxWidth: '24rem' } as const;

Focus and feedback

The ref targets the trigger button, not the hidden select. Connect visible feedback with aria-describedby. Selecting a value clears this application’s error; aria-invalid alone does not prevent submission.

Choose an available option.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator } from "@/components/ui/yads-select";

const fieldStyle = { display: 'grid', gap: '0.75rem', width: '100%', maxWidth: '24rem' } as const;

className customization

Style trigger and portalled content separately. This complete CSS recipe changes borders without replacing theme colors or the focus ring. A parent descendant selector cannot reach a body portal.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator } from "@/components/ui/yads-select";

const fieldStyle = { display: 'grid', gap: '0.75rem', width: '100%', maxWidth: '24rem' } as const;

Accessibility

  • Label the trigger. Use a visible native label with htmlFor matching the unique SelectTrigger id. Placeholder and group labels are not field labels.
  • Connect help and errors. Use aria-describedby and aria-invalid on Trigger; include explanatory text. Indicate required in the visible label and set required on Select. There is no automatic validation UI.
  • Keyboard. Tab reaches the trigger. Space, Enter, ArrowDown or ArrowUp opens. Within the list, arrows move, Home/End reach first/last enabled options, and typing jumps by text. Enter or Space selects. Escape dismisses without changing the value; selection and Escape return focus to the trigger. Tab is prevented while the popup is open: dismiss first to continue through the form.
  • Choose native when appropriate. This is a single-select listbox, not a searchable combobox or multiselect. Native Select preserves platform pickers and supports multiple selection.

Light is standalone by default. The nearest explicit ancestor .dark, .light or data-theme="dark|light" at the trigger is mirrored into the body portal, including live theme changes. If both exist on one ancestor, data-theme takes precedence. No provider or global variables are required.

API reference

Import Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem and SelectSeparator from @/components/ui/yads-select. SelectProps is the Radix Root props type. SelectScrollUpButton and SelectScrollDownButton are exported; Content already includes them. Other props follow Radix Select 2.4.1.

Trigger, Content and Item compose internal children and do not support asChild. Scroll buttons have fixed decorative children and also exclude asChild. Use className or style to customize these elements rather than replacing their underlying nodes.

On narrow screens, focus the table and scroll horizontally to read all columns.

Select parts, props, types, defaults and behavior
PartPropTypeDefaultDescription
Selectvalue / defaultValue / onValueChangestring / string / (value: string) => voidNot setControlled value with onValueChange(value), or initial uncontrolled value. Empty string clears to placeholder; Item values must be unique nonempty strings.
Selectopen / defaultOpen / onOpenChangeboolean / boolean / (open: boolean) => voidfalseControl the popup separately from selection, or use defaultOpen.
Selectname / form / autoCompletestringNot setHidden native select participates in a containing form or the form identified by form. name enables FormData. Put form on Select, not just Trigger.
Selectdisabled / required / dirboolean / boolean / ltr | rtlfalse / false / inheritedDisabled skips Tab and submission; required uses native constraints in forms. Set direction on Root for RTL positioning.
SelectTriggerid / aria-* / disabledNative button attributesNot setVisible button with role combobox. Label via htmlFor and id. aria-invalid styles error; aria-describedby connects help. Root disabled disables the whole field.
SelectValueplaceholder / childrenReactNodeNot setPlaceholder when value is empty; otherwise selected ItemText is shown. Optional children replace display, not the field label. Radix ignores Value className/style; style Trigger instead.
SelectContentposition / side / align / sideOffsetitem-aligned | popper / Radix placementpopper / bottom / start / 4Body portal with viewport and automatic scroll buttons. Radix collision avoidance; collisionPadding defaults to 10. item-aligned uses Radix alignment, not popper placement.
SelectContentonCloseAutoFocus / onEscapeKeyDown / onPointerDownOutsideRadix event handlersNot setPreserve focus return unless intentionally managing an alternative. Content ref is the listbox div.
SelectItemvalue / disabled / textValuestring / boolean / stringRequired / false / text contentOption with automatic text and selection indicator. textValue provides typeahead text for non-text children. Disabled options cannot be selected.
SelectGroup / SelectLabelchildrenReactNodeNot setPut Label inside Group to name the option group; it does not label the field trigger.
SelectSeparatorclassName / stylestring / CSSPropertiesNot setVisual separator between groups, excluded from keyboard options.
Styled partsclassName / style / refNative attributes / React.RefNot setTrigger ref: HTMLButtonElement; Value: HTMLSpanElement; Content, Item, Group, Label, Separator and scroll buttons: HTMLDivElement. Root has no DOM node or ref. No ref targets the hidden native select.

Form and reset boundaries

Radix 2.4.1 associates a visually hidden native select with a form, including external form IDs. A named enabled field contributes one string value to FormData; disabled fields are omitted. required on an empty value blocks native submission, but browser validation focuses the hidden select, not the visible trigger. Applications needing predictable visible error focus should validate explicitly and focus the trigger ref. aria-invalid alone does not enforce a constraint.

Native reset requests the value from the initial mount. Uncontrolled fields restore automatically. Controlled fields must accept the onValueChange request or set their desired value in the form’s onReset. Reset does not mean “clear”; use value="" to clear. Radix reset handling does not honor a canceled reset event; do not rely on preventDefault to preserve the selection. There is no readOnly, multiple, search, input onChange or native select ref API.

Playground defaults

Reset restores an enabled, empty controlled field showing “Choose produce”. The Select state control is documentation UI, not a variant prop. Typeahead matches options; it does not filter them.