Skip to content

Menu

A vertical dropdown list of actions or navigation options. Appears on trigger click and floats above page content.

Preview

Item types

TypeAppearance
DefaultStandard text with optional icon and shortcut
With iconLeading icon for visual identification
With shortcutRight-aligned keyboard shortcut hint
DividerHorizontal line separating groups
Disabled50% opacity, no interaction
DestructiveRed text and icon for dangerous actions

Props

PropTypeDefaultDescription
itemsMenuItem[]--Menu items array
onSelect(value: string) => void--Item selection handler
align'start' | 'end''start'Alignment relative to trigger
FieldTypeDescription
labelstringItem text
valuestringSelection value
iconReactNodeLeading icon
shortcutstringKeyboard shortcut hint
dangerbooleanDestructive styling
disabledbooleanDisables the item
dividerbooleanRenders a divider instead

Code example

React

tsx
import { Menu, MenuTrigger } from '@thepace/lexicon/components';

<MenuTrigger>
  <Button variant="secondary">Actions</Button>
  <Menu items={[
    { label: 'Edit', value: 'edit', shortcut: '⌘E' },
    { label: 'Duplicate', value: 'duplicate' },
    { divider: true },
    { label: 'Delete', value: 'delete', danger: true },
  ]} onSelect={handleAction} />
</MenuTrigger>

Vanilla HTML

html
<div class="lex-menu" role="menu">
  <button class="lex-menu__item" role="menuitem">
    <span class="lex-menu__label">Edit</span>
    <span class="lex-menu__shortcut">⌘E</span>
  </button>
  <div class="lex-menu__divider" role="separator"></div>
  <button class="lex-menu__item lex-menu__item--danger" role="menuitem">
    <span class="lex-menu__label">Delete</span>
  </button>
</div>

CSS class reference

ClassPurpose
.lex-menuFloating container
.lex-menu__itemMenu item button
.lex-menu__item--activeHighlighted item
.lex-menu__item--dangerDestructive item (red)
.lex-menu__item--disabledDisabled item
.lex-menu__iconLeading icon
.lex-menu__labelItem text
.lex-menu__shortcutKeyboard hint
.lex-menu__dividerSection separator

Accessibility

  • Container uses role="menu".
  • Items use role="menuitem".
  • Dividers use role="separator".
  • Arrow keys navigate between items. Home/End jump to first/last.
  • Escape closes the menu and returns focus to the trigger.
  • Disabled items are skipped in keyboard navigation.

Guidelines

Do

  • Group related items with dividers.
  • Place destructive actions at the bottom, separated by a divider.
  • Show keyboard shortcuts for power users.

Don't

  • Don't put more than 10 items in a single menu — use sub-menus or reorganise.
  • Don't mix navigation links and action items in the same menu.

Released under the MIT License. A product by the pace.