Skip to Content

Select

Select is a composable, Windows 98 styled dropdown built from small parts, following the shadcn/ui structure. Compose a SelectTrigger (with a SelectValue) and a SelectContent of SelectItems. For a plain browser dropdown with native form and mobile semantics, use SelectNative.

Composition

Use the following composition to build a Select:

Select ├── SelectTrigger │ └── SelectValue └── SelectContent ├── SelectItem ├── SelectSeparator └── SelectGroup ├── SelectLabel ├── SelectItem └── SelectItem

Props

Select

The root. Owns selection state and provides context to the parts. Renders no visible element of its own (plus a hidden form input when name is set).

PropTypeDefaultDescription
valuestring-Selected value (controlled).
defaultValuestring-Initial selected value (uncontrolled).
onValueChange(value: string) => void-Called with the next value on selection.
openboolean-Popup open state (controlled).
defaultOpenbooleanfalseInitial popup open state (uncontrolled).
onOpenChange(open: boolean) => void-Called when the popup opens or closes.
disabledbooleanfalseDisables the trigger and prevents opening.
namestring-Name for the hidden form input. Omit for UI-only selects.
requiredboolean-Marks the hidden form input as required.

SelectTrigger

The button that opens the listbox, rendering the Windows 98 arrow affordance. Accepts native button props (including id, className).

SelectValue

Shows the selected item’s label inside the trigger.

PropTypeDefaultDescription
placeholderReactNode-Shown when no value is selected.

SelectContent

The portalled popup listbox. Handles positioning, keyboard navigation, typeahead, the custom scrollbar, and dismissal. Accepts native ul props.

PropTypeDefaultDescription
maxHeightnumber | string-Upper bound for the listbox height before it scrolls.

SelectItem

A selectable option. Its plain-text children double as the display + typeahead label.

PropTypeDefaultDescription
valuestring-The value committed when the item is chosen.
disabledbooleanfalsePrevents selection of this item.
textValuestring-Label used for display/typeahead when children is not a plain string (e.g. contains an icon).

SelectGroup, SelectLabel, SelectSeparator

SelectGroup wraps related items and is labelled by its SelectLabel. SelectSeparator draws a divider between items or groups.

Examples

Custom select

Groups and labels

Native select

Scrollable options

Viewport edge detection

Native select

SelectNative wraps the browser’s <select> element for cases that need real native form behavior or the native mobile picker. It takes label, name, and standard select props, with native <option> children.

ARIA

The trigger is a combobox with aria-haspopup="listbox", aria-expanded, and aria-controls. The popup is a listbox of options that expose aria-selected and aria-disabled. Groups use role="group" associated with their SelectLabel through aria-labelledby.

Keyboard

KeyBehavior
Enter / Space / ArrowDown / ArrowUpOpens the select.
ArrowUp / ArrowDownMoves through options while open.
Home / EndJumps to the first or last option.
Printable charactersMoves focus to the next option whose label starts with the typed buffer.
Enter / SpaceSelects the focused option.
EscapeCloses without selecting.
TabCloses and moves focus onward.

SSR

Select is a client component through the package root. Initial selected values should be stable between server and client to avoid hydration drift.

Last updated on