Select
A closed list of choices.
84% done
Status is required.
In context
New task
New task
Status is required.
Native
Props
| Prop | Type | Required | Default |
|---|---|---|---|
options | (SelectOption | SelectOptionGroup)[] | Yes | — |
value | string | undefined | No | — |
defaultValue | string | undefined | No | — |
onValueChange | ((value: string) => void) | undefined | No | — |
placeholder | string | undefined | No | — |
disabled | boolean | undefined | No | — |
size | "sm" | "md" | "lg" | undefined | No | md |
className | string | undefined | No | — |
invalid | boolean | undefined | No | — |
aria-label | string | undefined | No | — |
native | boolean | undefined | No | — |
id | string | undefined | No | — |
name | string | undefined | No | — |
required | boolean | undefined | No | — |
Accessibility
A real Radix select: the trigger is a <button> with aria-haspopup and aria-expanded, the list a role="listbox". Arrow keys move, typing jumps to a match, Enter picks, Escape closes; a disabled option is announced as such.
data-rebar-* attributes
data-rebar-component="select" on the trigger, with data-rebar-size; .rebar-select-content on the popover.
Migrating to Ant Design
AntD's Select takes options, value and onChange: a close, low-risk rename.
Option groups
options may mix plain options with { label, options: [...] } groups. Each group renders its label as a small uppercase heading (an ARIA group named by it) above its options, with a hairline between groups.
<Select aria-label="Food" options={[{ value: "none", label: "None" }, { label: "Fruit", options: [{ value: "apple", label: "Apple" }] }]} />Tokens
Custom properties, set on the component or any ancestor. The default is what applies when one is unset. 1 of 22 were added in 1.1.0 and are marked.
| Property | Default | |
|---|---|---|
--rebar-select-background | var(--rebar-color-bg-raised) | |
--rebar-select-border-color | var(--rebar-color-border, #e0e0e0) | |
--rebar-select-border-width | 1.5px | |
--rebar-select-color | var(--rebar-color-text-primary, #212121) | |
--rebar-select-disabled-opacity | 0.5 | 1.1 |
--rebar-select-focus-border-color | var(--rebar-color-primary) | |
--rebar-select-focus-outline | none | |
--rebar-select-focus-outline-offset | 0px | |
--rebar-select-focus-shadow | 0 0 0 4px color-mix(in srgb, var(--rebar-color-primary) 18%, transparent) | |
--rebar-select-font-size | var(--rebar-font-size-sm, 14px) | |
--rebar-select-font-weight | 400 | |
--rebar-select-line-height | normal | |
--rebar-select-min-height | 46px | |
--rebar-select-min-height-lg | 54px | |
--rebar-select-min-height-sm | 36px | |
--rebar-select-min-width | 160px | |
--rebar-select-native-display | inline-block | |
--rebar-select-native-width | auto | |
--rebar-select-padding | 0 16px 0 18px | |
--rebar-select-padding-lg | 0 20px 0 22px | |
--rebar-select-padding-sm | 0 12px 0 14px | |
--rebar-select-radius | 999px |