Skip to main content

Dropdown menu

A menu of actions opened from a button.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Row actions.

  • Use it when: More actions than fit, or actions people use now and then.
  • Not when: Choosing a value for a field (select), or the one main action (a button).

Instead:

How Dense data uses it​

A menu or dialog
Use elevation.overlay and a dimmed page for dialogs
Not A border only
Floating things need a shadow so they read as on top.
An action on one row or item
Use Icon button, ghost, compact
Not Button secondary in every row
Rows repeat dozens of times; a quiet icon keeps the table readable.

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 runs; Escape closes and returns focus.undefined

Test before you ship:

  • The trigger says it opens a menu and whether it is open. undefined

Use it in code​

npx open-ds add dropdown-menu

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Dropdown menu reads 17 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 Dropdown menu's tokens to change Dropdown menu 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
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
Content
Paddingcomponent.dropdown-menu.content.paddingcomponent-spacing-map.x1var(--dropdown-menu-content-padding)space.4:0.25rem
Text
Changes with theme
component.dropdown-menu.content.labelcolor.text.primaryvar(--dropdown-menu-content-label)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Border widthcomponent.dropdown-menu.content.border-widthborder-width.defaultvar(--dropdown-menu-content-border-width)border-width.1:1px
Border
Changes with theme
component.dropdown-menu.content.bordercolor.border.defaultvar(--dropdown-menu-content-border)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Item
Gapcomponent.dropdown-menu.item.gapspace.gap.defaultvar(--dropdown-menu-item-gap)space.8:0.5rem
Padding, left and rightcomponent.dropdown-menu.item.padding-xspace.inset.cell-xvar(--dropdown-menu-item-padding-x)space.12:0.75rem
Cornercomponent.dropdown-menu.item.radiusradius.badgevar(--dropdown-menu-item-radius)radius.0:0rem
Text sizecomponent.dropdown-menu.item.font-sizetype.body.font-sizevar(--dropdown-menu-item-font-size)font.size.14:0.875rem
Sunken
Changes with theme
on focus
component.dropdown-menu.item.sunkencolor.surface.sunkenvar(--dropdown-menu-item-sunken)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Disabled
when disabled
component.dropdown-menu.item.disabledopacity.disabledvar(--dropdown-menu-item-disabled)opacity.40:0.4
Iconcomponent.dropdown-menu.item.iconsize.iconvar(--dropdown-menu-item-icon)size.16:1rem
Dropdown menu
Text
Changes with theme
component.dropdown-menu.labelcolor.status.dangervar(--dropdown-menu-label)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Fill
Changes with theme
component.dropdown-menu.backgroundcolor.border.defaultvar(--dropdown-menu-background)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38