Select
Selects one option from a list in a popover.
Workspace
select-demo.tsx
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
npm
yarn
pnpm
bun
Composition
SelectOwns the value and field state.
SelectLabelSelectTriggerSelectDescriptionSelectErrorSelectContentSelectSectionOptionalRepeatsSelectItemRepeats
Described options
Set textValue to the option name, so the trigger shows only the name.
FrameworkChoose the framework for this project.
select-descriptions-demo.tsx
Disabled
Archived workspaceThis workspace is no longer available.
select-disabled-demo.tsx
Sections
Time zone
select-sections-demo.tsx
Invalid selection
Set isInvalid while the controlled value is empty.
WorkspaceChoose a workspace to continue.
select-invalid-demo.tsx
Sizes
The list keeps one row height, so options stay easy to touch.
select-sizes-demo.tsx
API reference
vip/ui adds or changes the props below. For all other props, see React Aria Select (opens in a new tab).
Select
- size: "xs" | "sm" | "md" | "lg" | "xl" = "lg"
- Sets the size of the trigger. The list keeps one row height.
- options: SelectOption[]
- Options for the default layout. Each option has an id, a name, and an optional description.
- label: string
- Label above the trigger in the default layout. When you compose the parts, add SelectLabel or pass aria-label.
- description: string
- Help text below the trigger in the default layout.
- value: string
- The selected option id, not its name. Sets selectedKey.
- defaultValue: string
- The option id that is selected at first, not its name. Sets defaultSelectedKey.
- onValueChange: (value: string) => void
- Receives the selected option id, or an empty string when the selection is cleared. onSelectionChange also runs.
- placeholder: string = "Select an option"
- Text in the trigger when no option is selected.
SelectSection
- title: string
- The section heading. It stays at the top while the list scrolls.