Skip to main content

Select

One choice from a list, in a menu.

In Content first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Content first: A closed list whose options need more than plain text. Not for a short list readers should see at once.

  • 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​

  • Write to one person: "you", not "users".
  • Short sentences with room to breathe.
  • Explain why before asking for anything.
  • Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Browse guides

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

Content 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)Lightstone.light.0:#FFFFFFDarkstone.dark.50:#1F1B16
Input border @
Changes with theme
component.input.bordercolor.border.strongvar(--input-border)Lightstone.light.500:#7A7062Darkstone.dark.400:#A39A8B
Input border focus
Changes with theme
on focus
component.input.border.focuscolor.border.focusvar(--input-border-focus)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Input text
Changes with theme
component.input.textcolor.text.primaryvar(--input-text)Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8
Input placeholder
Changes with theme
component.input.placeholdercolor.text.mutedvar(--input-placeholder)Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B
Input heightcomponent.input.heightsize.control.defaultvar(--input-height)size.48:3rem
Input padding xcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.20:1.25rem
Input radiuscomponent.input.radiusradius.controlvar(--input-radius)radius.8:0.5rem
Input font sizecomponent.input.font-sizetype.body.font-sizevar(--input-font-size)font.size.18:1.125rem
Overlay background
Changes with theme
component.overlay.backgroundcolor.surface.raisedvar(--overlay-background)Lightstone.light.0:#FFFFFFDarkstone.dark.100:#2E2A24
Overlay radiuscomponent.overlay.radiusradius.containervar(--overlay-radius)radius.12:0.75rem
Overlay shadow
Changes with theme
component.overlay.shadowelevation.overlayvar(--overlay-shadow)Lightshadow.overlay:0px 12px 32px 0px #1F1B1629Darkshadow.overlay-dark:0px 12px 32px 0px #00000080
Overlay item heightcomponent.overlay.item-heightsize.control.defaultvar(--overlay-item-height)size.48:3rem
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.source-serif-4:"Source Serif 4", Georgia, serif
Border widthcomponent.select.trigger.border-widthborder-width.defaultvar(--select-trigger-border-width)border-width.1:1px
Select
Focus
on focus
component.select.focusborder-width.focusvar(--select-focus)border-width.2:2px
Canvas
Changes with theme
on focus
component.select.canvascolor.surface.canvasvar(--select-canvas)Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D
Sizecomponent.select.sizesize.iconvar(--select-size)size.16:1rem
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)Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8
Border widthcomponent.select.content.border-widthborder-width.defaultvar(--select-content-border-width)border-width.1:1px
Border
Changes with theme
component.select.content.bordercolor.border.defaultvar(--select-content-border)Lightstone.light.200:#E4DDD0Darkstone.dark.100:#2E2A24
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.48:3rem
Cornercomponent.select.item.radiusradius.badgevar(--select-item-radius)radius.999:9999px
Text sizecomponent.select.item.font-sizetype.body.font-sizevar(--select-item-font-size)font.size.18:1.125rem
Sunken
Changes with theme
on focus
component.select.item.sunkencolor.surface.sunkenvar(--select-item-sunken)Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24
Disabled
when disabled
component.select.item.disabledopacity.disabledvar(--select-item-disabled)opacity.40:0.4