Skip to main content

Select

One choice from a list, in a menu.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Picks one value in filters and forms.

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

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

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

Dense data 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)Lightslate.light.0:#FFFFFFDarkslate.dark.50:#161B23
Input border @
Changes with theme
component.input.bordercolor.border.strongvar(--input-border)Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD
Input border focus
Changes with theme
on focus
component.input.border.focuscolor.border.focusvar(--input-border-focus)Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6
Input text
Changes with theme
component.input.textcolor.text.primaryvar(--input-text)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Input placeholder
Changes with theme
component.input.placeholdercolor.text.mutedvar(--input-placeholder)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Input heightcomponent.input.heightsize.control.defaultvar(--input-height)size.32:2rem
Input padding xcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.12:0.75rem
Input radiuscomponent.input.radiusradius.controlvar(--input-radius)radius.2:0.125rem
Input font sizecomponent.input.font-sizetype.body.font-sizevar(--input-font-size)font.size.14:0.875rem
Overlay background
Changes with theme
component.overlay.backgroundcolor.surface.raisedvar(--overlay-background)Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38
Overlay radiuscomponent.overlay.radiusradius.containervar(--overlay-radius)radius.4:0.25rem
Overlay shadow
Changes with theme
component.overlay.shadowelevation.overlayvar(--overlay-shadow)Lightshadow.overlay:0px 8px 24px 0px #0D111729Darkshadow.overlay-dark:0px 8px 24px 0px #00000080
Overlay item heightcomponent.overlay.item-heightsize.control.defaultvar(--overlay-item-height)size.32:2rem
Trigger
Gapcomponent.select.trigger.gapspace.gap.defaultvar(--select-trigger-gap)space.8:0.5rem
Font familycomponent.select.trigger.font-familytype.body.font-familyvar(--select-trigger-font-family)font.family.ibm-plex-sans:"IBM Plex Sans", system-ui, sans-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)Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117
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)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
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)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Item
Gapcomponent.select.item.gapspace.gap.defaultvar(--select-item-gap)space.8:0.5rem
Padding leftcomponent.select.item.padding-leftspace.inset.cell-xvar(--select-item-padding-left)space.12:0.75rem
Padding rightcomponent.select.item.padding-rightcomponent-spacing-map.x8var(--select-item-padding-right)space.32:2rem
Cornercomponent.select.item.radiusradius.badgevar(--select-item-radius)radius.0:0rem
Text sizecomponent.select.item.font-sizetype.body.font-sizevar(--select-item-font-size)font.size.14:0.875rem
Sunken
Changes with theme
on focus
component.select.item.sunkencolor.surface.sunkenvar(--select-item-sunken)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Disabled
when disabled
component.select.item.disabledopacity.disabledvar(--select-item-disabled)opacity.40:0.4