Skip to main content

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​

Start Storybook to see it live: npm run storybook

When 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:

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: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedArrows 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.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
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 heightcomponent.input.heightsize.control.defaultvar(--input-height)size.52:3.25rem
Input padding xcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.24:1.5rem
Input radiuscomponent.input.radiusradius.controlvar(--input-radius)radius.6:0.375rem
Input font sizecomponent.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 radiuscomponent.overlay.radiusradius.containervar(--overlay-radius)radius.8:0.5rem
Overlay shadowcomponent.overlay.shadowelevation.overlayvar(--overlay-shadow)shadow.none:0px 0px 0px 0px #00000000
Overlay item heightcomponent.overlay.item-heightsize.control.defaultvar(--overlay-item-height)size.52:3.25rem
Trigger
Gapcomponent.select.trigger.gapspace.gap.defaultvar(--select-trigger-gap)space.16:1rem
Font familycomponent.select.trigger.font-familytype.body.font-familyvar(--select-trigger-font-family)font.family.atkinson-hyperlegible:"Atkinson Hyperlegible", Verdana, sans-serif
Border widthcomponent.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
Sizecomponent.select.sizesize.iconvar(--select-size)size.20:1.25rem
Content
Paddingcomponent.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 widthcomponent.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
Gapcomponent.select.item.gapspace.gap.defaultvar(--select-item-gap)space.16:1rem
Padding leftcomponent.select.item.padding-leftspace.inset.cell-xvar(--select-item-padding-left)space.16:1rem
Padding rightcomponent.select.item.padding-rightcomponent-spacing-map.x8var(--select-item-padding-right)space.56:3.5rem
Cornercomponent.select.item.radiusradius.badgevar(--select-item-radius)radius.4:0.25rem
Text sizecomponent.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