Skip to main content

Dropdown menu

A menu of actions opened from a button.

In Multi-brand

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Multi-brand: The account menu.

  • 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 Multi-brand uses it​

A menu or dialog
Use elevation.overlay and a dimmed page
Not No shadow
The shadow shows a menu or dialog floats above the page. Without it, it blends into the cards.
An action on one row or item
Use Button ghost with a word
Not An icon alone
A word says what will happen.

Words​

  • Shared structure: object, state, next step.
  • Brand tone lives in headlines and marketing copy, not in errors.
  • Errors and confirmations read the same in every brand.
  • Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Get started

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

Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and 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)Aster Lightslate-deep.light.0:#FFFFFFAster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.0:#FFFFFFBirch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.0:#FFFFFFCoral Darkslate-deep.dark.100:#1E293B
Overlay radius
Changes with theme
component.overlay.radiusradius.containervar(--overlay-radius)Aster Lightradius.8:0.5remAster Darkradius.8:0.5remBirch Lightradius.16:1remBirch Darkradius.16:1remCoral Lightradius.20:1.25remCoral Darkradius.20:1.25rem
Overlay shadow
Changes with theme
component.overlay.shadowelevation.overlayvar(--overlay-shadow)Aster Lightshadow.overlay:0px 12px 32px 0px #0F172A29Aster Darkshadow.overlay-dark:0px 12px 32px 0px #00000080Birch Lightshadow.overlay:0px 12px 32px 0px #0F172A29Birch Darkshadow.overlay-dark:0px 12px 32px 0px #00000080Coral Lightshadow.overlay:0px 12px 32px 0px #0F172A29Coral Darkshadow.overlay-dark:0px 12px 32px 0px #00000080
Overlay item heightcomponent.overlay.item-heightsize.control.defaultvar(--overlay-item-height)size.44:2.75rem
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)Aster Lightslate-deep.light.900:#0F172AAster Darkslate-deep.dark.900:#F8FAFCBirch Lightslate-deep.light.900:#0F172ABirch Darkslate-deep.dark.900:#F8FAFCCoral Lightslate-deep.light.900:#0F172ACoral Darkslate-deep.dark.900:#F8FAFC
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)Aster Lightslate-deep.light.200:#E2E8F0Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.200:#E2E8F0Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.200:#E2E8F0Coral Darkslate-deep.dark.100:#1E293B
Item
Gapcomponent.dropdown-menu.item.gapspace.gap.defaultvar(--dropdown-menu-item-gap)space.12:0.75rem
Padding, left and rightcomponent.dropdown-menu.item.padding-xspace.inset.cell-xvar(--dropdown-menu-item-padding-x)space.16:1rem
Corner
Changes with theme
component.dropdown-menu.item.radiusradius.badgevar(--dropdown-menu-item-radius)Aster Lightradius.4:0.25remAster Darkradius.4:0.25remBirch Lightradius.999:9999pxBirch Darkradius.999:9999pxCoral Lightradius.999:9999pxCoral Darkradius.999:9999px
Text sizecomponent.dropdown-menu.item.font-sizetype.body.font-sizevar(--dropdown-menu-item-font-size)font.size.16:1rem
Sunken
Changes with theme
on focus
component.dropdown-menu.item.sunkencolor.surface.sunkenvar(--dropdown-menu-item-sunken)Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B
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)Aster Lightred.light.600:#C42B2BAster Darkred.dark.600:#F28B8BBirch Lightred.light.600:#C42B2BBirch Darkred.dark.600:#F28B8BCoral Lightred.light.600:#C42B2BCoral Darkred.dark.600:#F28B8B
Fill
Changes with theme
component.dropdown-menu.backgroundcolor.border.defaultvar(--dropdown-menu-background)Aster Lightslate-deep.light.200:#E2E8F0Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.200:#E2E8F0Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.200:#E2E8F0Coral Darkslate-deep.dark.100:#1E293B