Skip to main content

Context menu

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

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Right-click on a row, for experts.

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

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

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
Transition panels durationcomponent.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration)duration.fast:120ms
Sub
Trigger radiuscomponent.context-menu.sub.trigger.radiusradius.badgevar(--context-menu-sub-trigger-radius)radius.0:0rem
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.14:0.875rem
Trigger background focus
Changes with theme
on focus
component.context-menu.sub.trigger.background-focuscolor.surface.sunkenvar(--context-menu-sub-trigger-background-focus)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Trigger label focus
Changes with theme
on focus
component.context-menu.sub.trigger.label-focuscolor.text.primaryvar(--context-menu-sub-trigger-label-focus)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Trigger padding leftcomponent.context-menu.sub.trigger.padding-leftcomponent-spacing-map.x8var(--context-menu-sub-trigger-padding-left)space.32:2rem
Trigger background open
Changes with theme
when open
component.context-menu.sub.trigger.background-opencolor.surface.sunkenvar(--context-menu-sub-trigger-background-open)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Trigger label open
Changes with theme
when open
component.context-menu.sub.trigger.label-opencolor.text.primaryvar(--context-menu-sub-trigger-label-open)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Trigger icon sizecomponent.context-menu.sub.trigger.icon-sizesize.iconvar(--context-menu-sub-trigger-icon-size)size.16:1rem
Trigger label
Changes with theme
component.context-menu.sub.trigger.labelcolor.text.mutedvar(--context-menu-sub-trigger-label)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Content radiuscomponent.context-menu.sub.content.radiusradius.controlvar(--context-menu-sub-content-radius)radius.2:0.125rem
Content background
Changes with theme
component.context-menu.sub.content.backgroundcolor.surface.raisedvar(--context-menu-sub-content-background)Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38
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)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Content shadow
Changes with theme
component.context-menu.sub.content.shadowelevation.overlayvar(--context-menu-sub-content-shadow)Lightshadow.overlay:0px 8px 24px 0px #0D111729Darkshadow.overlay-dark:0px 8px 24px 0px #00000080
Content
Cornercomponent.context-menu.content.radiusradius.controlvar(--context-menu-content-radius)radius.2:0.125rem
Fill
Changes with theme
component.context-menu.content.backgroundcolor.surface.raisedvar(--context-menu-content-background)Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38
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)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
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.8:0.5rem
Cornercomponent.context-menu.item.radiusradius.badgevar(--context-menu-item-radius)radius.0:0rem
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.14:0.875rem
Background focus
Changes with theme
on focus
component.context-menu.item.background-focuscolor.surface.sunkenvar(--context-menu-item-background-focus)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Label focus
Changes with theme
on focus
component.context-menu.item.label-focuscolor.text.primaryvar(--context-menu-item-label-focus)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
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.32:2rem
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.16:1rem
Label 2
Changes with theme
component.context-menu.item.label-2color.text.mutedvar(--context-menu-item-label-2)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Checkbox
Item gapcomponent.context-menu.checkbox.item.gapspace.gap.defaultvar(--context-menu-checkbox-item-gap)space.8:0.5rem
Item radiuscomponent.context-menu.checkbox.item.radiusradius.badgevar(--context-menu-checkbox-item-radius)radius.0:0rem
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.32:2rem
Item font sizecomponent.context-menu.checkbox.item.font-sizetype.body.font-sizevar(--context-menu-checkbox-item-font-size)font.size.14:0.875rem
Item background focus
Changes with theme
on focus
component.context-menu.checkbox.item.background-focuscolor.surface.sunkenvar(--context-menu-checkbox-item-background-focus)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Item label focus
Changes with theme
on focus
component.context-menu.checkbox.item.label-focuscolor.text.primaryvar(--context-menu-checkbox-item-label-focus)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
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.16:1rem
Context menu
Icon sizecomponent.context-menu.icon-sizesize.iconvar(--context-menu-icon-size)size.16:1rem
Radio
Item gapcomponent.context-menu.radio.item.gapspace.gap.defaultvar(--context-menu-radio-item-gap)space.8:0.5rem
Item radiuscomponent.context-menu.radio.item.radiusradius.badgevar(--context-menu-radio-item-radius)radius.0:0rem
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.32:2rem
Item font sizecomponent.context-menu.radio.item.font-sizetype.body.font-sizevar(--context-menu-radio-item-font-size)font.size.14:0.875rem
Item background focus
Changes with theme
on focus
component.context-menu.radio.item.background-focuscolor.surface.sunkenvar(--context-menu-radio-item-background-focus)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Item label focus
Changes with theme
on focus
component.context-menu.radio.item.label-focuscolor.text.primaryvar(--context-menu-radio-item-label-focus)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
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.16:1rem
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.14:0.875rem
Weightcomponent.context-menu.label.font-weighttype.label.font-weightvar(--context-menu-label-font-weight)font.weight.500:500
Text
Changes with theme
component.context-menu.label.labelcolor.text.primaryvar(--context-menu-label-label)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Padding leftcomponent.context-menu.label.padding-leftcomponent-spacing-map.x8var(--context-menu-label-padding-left)space.32:2rem
Separator
Fill
Changes with theme
component.context-menu.separator.backgroundcolor.border.defaultvar(--context-menu-separator-background)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Shortcut
Text sizecomponent.context-menu.shortcut.font-sizetype.caption.font-sizevar(--context-menu-shortcut-font-size)font.size.12:0.75rem
Text
Changes with theme
component.context-menu.shortcut.labelcolor.text.mutedvar(--context-menu-shortcut-label)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38