Skip to main content

Context menu

A menu of actions on right-click or long-press.

Left out of Brand expressive Context menu is for power users, and people who don't know to right-click never find it. Brand expressive serves new customers deciding if they care. Use instead: Button, Popover

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

  • Use it when: Power users acting on an item in place, with the same actions also reachable elsewhere.
  • Not when: The only way to reach an action: people who don't know to right-click never find it.

Instead:

Words​

  • Headlines are short and bold. Three to six words.
  • Verbs that move: Join, Try, Go.
  • Playful in headlines, plain in errors.
  • Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.

The labels components use, from the voice tokens:

  • content.action.commit: Go
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Explore the drop

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedShift F10 or the menu key opens it; arrows move; Escape closes.undefined

Use it in code​

npx open-ds add context-menu

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

Tokens it reads​

Context menu reads 66 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 Context menu's tokens to change Context menu alone.

Changes with theme

Brand expressive 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
Transition panels durationcomponent.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration)duration.moderate:200ms
Sub
Trigger radiuscomponent.context-menu.sub.trigger.radiusradius.badgevar(--context-menu-sub-trigger-radius)radius.999:9999px
Trigger padding xcomponent.context-menu.sub.trigger.padding-xcomponent-spacing-map.x2var(--context-menu-sub-trigger-padding-x)space.8:0.5rem
Trigger padding ycomponent.context-menu.sub.trigger.padding-ycomponent-spacing-map.x2var(--context-menu-sub-trigger-padding-y)space.8:0.5rem
Trigger font sizecomponent.context-menu.sub.trigger.font-sizetype.body.font-sizevar(--context-menu-sub-trigger-font-size)font.size.17:1.0625rem
Trigger background focus
Changes with theme
on focus
component.context-menu.sub.trigger.background-focuscolor.surface.sunkenvar(--context-menu-sub-trigger-background-focus)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Trigger label focus
Changes with theme
on focus
component.context-menu.sub.trigger.label-focuscolor.text.primaryvar(--context-menu-sub-trigger-label-focus)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Trigger padding leftcomponent.context-menu.sub.trigger.padding-leftcomponent-spacing-map.x8var(--context-menu-sub-trigger-padding-left)space.64:4rem
Trigger background open
Changes with theme
when open
component.context-menu.sub.trigger.background-opencolor.surface.sunkenvar(--context-menu-sub-trigger-background-open)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Trigger label open
Changes with theme
when open
component.context-menu.sub.trigger.label-opencolor.text.primaryvar(--context-menu-sub-trigger-label-open)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Trigger icon sizecomponent.context-menu.sub.trigger.icon-sizesize.iconvar(--context-menu-sub-trigger-icon-size)size.20:1.25rem
Trigger label
Changes with theme
component.context-menu.sub.trigger.labelcolor.text.mutedvar(--context-menu-sub-trigger-label)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
Content radiuscomponent.context-menu.sub.content.radiusradius.controlvar(--context-menu-sub-content-radius)radius.999:9999px
Content background
Changes with theme
component.context-menu.sub.content.backgroundcolor.surface.raisedvar(--context-menu-sub-content-background)Lighttaupe.light.0:#FFFFFFDarktaupe.dark.100:#33241F
Content paddingcomponent.context-menu.sub.content.paddingcomponent-spacing-map.x1var(--context-menu-sub-content-padding)space.4:0.25rem
Content label
Changes with theme
component.context-menu.sub.content.labelcolor.text.primaryvar(--context-menu-sub-content-label)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Content shadow
Changes with theme
component.context-menu.sub.content.shadowelevation.overlayvar(--context-menu-sub-content-shadow)Lightshadow.overlay:0px 24px 48px 0px #1F141133Darkshadow.overlay-dark:0px 24px 48px 0px #00000099
Content
Cornercomponent.context-menu.content.radiusradius.controlvar(--context-menu-content-radius)radius.999:9999px
Fill
Changes with theme
component.context-menu.content.backgroundcolor.surface.raisedvar(--context-menu-content-background)Lighttaupe.light.0:#FFFFFFDarktaupe.dark.100:#33241F
Paddingcomponent.context-menu.content.paddingcomponent-spacing-map.x1var(--context-menu-content-padding)space.4:0.25rem
Text
Changes with theme
component.context-menu.content.labelcolor.text.primaryvar(--context-menu-content-label)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Shadow
Changes with theme
component.context-menu.content.shadowelevation.overlayvar(--context-menu-content-shadow)Lightshadow.overlayDarkshadow.overlay-dark
Item
Gapcomponent.context-menu.item.gapspace.gap.defaultvar(--context-menu-item-gap)space.16:1rem
Cornercomponent.context-menu.item.radiusradius.badgevar(--context-menu-item-radius)radius.999:9999px
Padding, left and rightcomponent.context-menu.item.padding-xcomponent-spacing-map.x2var(--context-menu-item-padding-x)space.8:0.5rem
Padding, top and bottomcomponent.context-menu.item.padding-ycomponent-spacing-map.x2var(--context-menu-item-padding-y)space.8:0.5rem
Text sizecomponent.context-menu.item.font-sizetype.body.font-sizevar(--context-menu-item-font-size)font.size.17:1.0625rem
Background focus
Changes with theme
on focus
component.context-menu.item.background-focuscolor.surface.sunkenvar(--context-menu-item-background-focus)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Label focus
Changes with theme
on focus
component.context-menu.item.label-focuscolor.text.primaryvar(--context-menu-item-label-focus)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Disabled opacity disabled
when disabled
component.context-menu.item.disabled-opacity-disabledopacity.disabledvar(--context-menu-item-disabled-opacity-disabled)opacity.40:0.4
Padding leftcomponent.context-menu.item.padding-leftcomponent-spacing-map.x8var(--context-menu-item-padding-left)space.64:4rem
Text
Changes with theme
destructive
component.context-menu.item.labelcolor.status.dangervar(--context-menu-item-label)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Background focus 2
Changes with theme
destructive, on focus
component.context-menu.item.background-focus-2color.status.dangervar(--context-menu-item-background-focus-2)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Label focus 2
Changes with theme
destructive, on focus
component.context-menu.item.label-focus-2color.status.dangervar(--context-menu-item-label-focus-2)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Icon sizecomponent.context-menu.item.icon-sizesize.iconvar(--context-menu-item-icon-size)size.20:1.25rem
Label 2
Changes with theme
component.context-menu.item.label-2color.text.mutedvar(--context-menu-item-label-2)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
Checkbox
Item gapcomponent.context-menu.checkbox.item.gapspace.gap.defaultvar(--context-menu-checkbox-item-gap)space.16:1rem
Item radiuscomponent.context-menu.checkbox.item.radiusradius.badgevar(--context-menu-checkbox-item-radius)radius.999:9999px
Item padding ycomponent.context-menu.checkbox.item.padding-ycomponent-spacing-map.x2var(--context-menu-checkbox-item-padding-y)space.8:0.5rem
Item padding rightcomponent.context-menu.checkbox.item.padding-rightcomponent-spacing-map.x2var(--context-menu-checkbox-item-padding-right)space.8:0.5rem
Item padding leftcomponent.context-menu.checkbox.item.padding-leftcomponent-spacing-map.x8var(--context-menu-checkbox-item-padding-left)space.64:4rem
Item font sizecomponent.context-menu.checkbox.item.font-sizetype.body.font-sizevar(--context-menu-checkbox-item-font-size)font.size.17:1.0625rem
Item background focus
Changes with theme
on focus
component.context-menu.checkbox.item.background-focuscolor.surface.sunkenvar(--context-menu-checkbox-item-background-focus)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Item label focus
Changes with theme
on focus
component.context-menu.checkbox.item.label-focuscolor.text.primaryvar(--context-menu-checkbox-item-label-focus)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Item disabled opacity disabled
when disabled
component.context-menu.checkbox.item.disabled-opacity-disabledopacity.disabledvar(--context-menu-checkbox-item-disabled-opacity-disabled)opacity.40:0.4
Item icon sizecomponent.context-menu.checkbox.item.icon-sizesize.iconvar(--context-menu-checkbox-item-icon-size)size.20:1.25rem
Context menu
Icon sizecomponent.context-menu.icon-sizesize.iconvar(--context-menu-icon-size)size.20:1.25rem
Radio
Item gapcomponent.context-menu.radio.item.gapspace.gap.defaultvar(--context-menu-radio-item-gap)space.16:1rem
Item radiuscomponent.context-menu.radio.item.radiusradius.badgevar(--context-menu-radio-item-radius)radius.999:9999px
Item padding ycomponent.context-menu.radio.item.padding-ycomponent-spacing-map.x2var(--context-menu-radio-item-padding-y)space.8:0.5rem
Item padding rightcomponent.context-menu.radio.item.padding-rightcomponent-spacing-map.x2var(--context-menu-radio-item-padding-right)space.8:0.5rem
Item padding leftcomponent.context-menu.radio.item.padding-leftcomponent-spacing-map.x8var(--context-menu-radio-item-padding-left)space.64:4rem
Item font sizecomponent.context-menu.radio.item.font-sizetype.body.font-sizevar(--context-menu-radio-item-font-size)font.size.17:1.0625rem
Item background focus
Changes with theme
on focus
component.context-menu.radio.item.background-focuscolor.surface.sunkenvar(--context-menu-radio-item-background-focus)Lighttaupe.light.100:#FCEFE6Darktaupe.dark.100:#33241F
Item label focus
Changes with theme
on focus
component.context-menu.radio.item.label-focuscolor.text.primaryvar(--context-menu-radio-item-label-focus)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Item disabled opacity disabled
when disabled
component.context-menu.radio.item.disabled-opacity-disabledopacity.disabledvar(--context-menu-radio-item-disabled-opacity-disabled)opacity.40:0.4
Item icon sizecomponent.context-menu.radio.item.icon-sizesize.iconvar(--context-menu-radio-item-icon-size)size.20:1.25rem
Text
Padding, left and rightcomponent.context-menu.label.padding-xcomponent-spacing-map.x2var(--context-menu-label-padding-x)space.8:0.5rem
Padding, top and bottomcomponent.context-menu.label.padding-ycomponent-spacing-map.x2var(--context-menu-label-padding-y)space.8:0.5rem
Text sizecomponent.context-menu.label.font-sizetype.body.font-sizevar(--context-menu-label-font-size)font.size.17:1.0625rem
Weightcomponent.context-menu.label.font-weighttype.label.font-weightvar(--context-menu-label-font-weight)font.weight.700:700
Text
Changes with theme
component.context-menu.label.labelcolor.text.primaryvar(--context-menu-label-label)Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3
Padding leftcomponent.context-menu.label.padding-leftcomponent-spacing-map.x8var(--context-menu-label-padding-left)space.64:4rem
Separator
Fill
Changes with theme
component.context-menu.separator.backgroundcolor.border.defaultvar(--context-menu-separator-background)Lighttaupe.light.200:#F2DCCFDarktaupe.dark.100:#33241F
Shortcut
Text sizecomponent.context-menu.shortcut.font-sizetype.caption.font-sizevar(--context-menu-shortcut-font-size)font.size.14:0.875rem
Text
Changes with theme
component.context-menu.shortcut.labelcolor.text.mutedvar(--context-menu-shortcut-label)Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lighttaupe.light.200 · #F2DCCFDarktaupe.dark.100 · #33241F