Select
One choice from a list, in a menu.
Left out of Accessible first A component joins only when it works with any assistive technology. The native select covers the same choice and every assistive technology understands it. Use instead: Native select, Radio group
See it live
npm run storybookWhen to use it
- Use it when: Four or more options, a known closed list, or a setting with a default.
- Not when: Two to five options people should see (radio group), or many flags (checkboxes).
Instead:
- Radio group: A short list shown at once.
- Combobox: Type to find in a long list.
- Native select: The system picker.
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrows move; Enter picks; Escape closes. | undefined |
Test before you ship:
- It has a visible label; the chosen value is announced. undefined
Use it in code
npx open-ds add select
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Select reads 30 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Select's tokens to change Select alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Input background Changes with theme | component.input.backgroundcolor.surface.defaultvar(--input-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.50:#141414 |
| Input border @ Changes with theme | component.input.bordercolor.border.strongvar(--input-border) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Input border focus Changes with theme on focus | component.input.border.focuscolor.border.focusvar(--input-border-focus) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Input text Changes with theme | component.input.textcolor.text.primaryvar(--input-text) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Input placeholder Changes with theme | component.input.placeholdercolor.text.mutedvar(--input-placeholder) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Input height | component.input.heightsize.control.defaultvar(--input-height) | size.52:3.25rem |
| Input padding x | component.input.padding-xspace.inset.control-xvar(--input-padding-x) | space.24:1.5rem |
| Input radius | component.input.radiusradius.controlvar(--input-radius) | radius.6:0.375rem |
| Input font size | component.input.font-sizetype.body.font-sizevar(--input-font-size) | font.size.19:1.1875rem |
| Overlay background Changes with theme | component.overlay.backgroundcolor.surface.raisedvar(--overlay-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Overlay radius | component.overlay.radiusradius.containervar(--overlay-radius) | radius.8:0.5rem |
| Overlay shadow | component.overlay.shadowelevation.overlayvar(--overlay-shadow) | shadow.none:0px 0px 0px 0px #00000000 |
| Overlay item height | component.overlay.item-heightsize.control.defaultvar(--overlay-item-height) | size.52:3.25rem |
| Trigger | ||
| Gap | component.select.trigger.gapspace.gap.defaultvar(--select-trigger-gap) | space.16:1rem |
| Font family | component.select.trigger.font-familytype.body.font-familyvar(--select-trigger-font-family) | font.family.atkinson-hyperlegible:"Atkinson Hyperlegible", Verdana, sans-serif |
| Border width | component.select.trigger.border-widthborder-width.defaultvar(--select-trigger-border-width) | border-width.2:2px |
| Select | ||
| Focus on focus | component.select.focusborder-width.focusvar(--select-focus) | border-width.3:3px |
| Canvas Changes with theme on focus | component.select.canvascolor.surface.canvasvar(--select-canvas) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Size | component.select.sizesize.iconvar(--select-size) | size.20:1.25rem |
| Content | ||
| Padding | component.select.content.paddingcomponent-spacing-map.x1var(--select-content-padding) | space.4:0.25rem |
| Text Changes with theme | component.select.content.labelcolor.text.primaryvar(--select-content-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Border width | component.select.content.border-widthborder-width.defaultvar(--select-content-border-width) | border-width.2:2px |
| Border Changes with theme | component.select.content.bordercolor.border.defaultvar(--select-content-border) | Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222 |
| Item | ||
| Gap | component.select.item.gapspace.gap.defaultvar(--select-item-gap) | space.16:1rem |
| Padding left | component.select.item.padding-leftspace.inset.cell-xvar(--select-item-padding-left) | space.16:1rem |
| Padding right | component.select.item.padding-rightcomponent-spacing-map.x8var(--select-item-padding-right) | space.56:3.5rem |
| Corner | component.select.item.radiusradius.badgevar(--select-item-radius) | radius.4:0.25rem |
| Text size | component.select.item.font-sizetype.body.font-sizevar(--select-item-font-size) | font.size.19:1.1875rem |
| Sunken Changes with theme on focus | component.select.item.sunkencolor.surface.sunkenvar(--select-item-sunken) | Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222 |
| Disabled when disabled | component.select.item.disabledopacity.disabledvar(--select-item-disabled) | opacity.50:0.5 |