Skip to content
Fleetline

Menu button

Usage

Use a menu button to offer a short list of actions on one thing: a work order, a van, a table view. For choosing a value in a form, use a select or combobox; for navigation, use links (top nav, side nav) — never role="menu" for site navigation.

Anatomy

  1. Trigger — .btn or .icon-btn with aria-haspopup="menu", aria-expanded, aria-controls, commandfor/command="toggle-popover"
  2. Surface — div.menu[popover][role=menu], anchored with CSS anchor positioning
  3. Item — button.menu__item[role=menuitem|menuitemcheckbox|menuitemradio]
  4. Leading icon / check — .menu__icon / .menu__check
  5. Label — .menu__label
  6. Shortcut or submenu chevron — kbd.menu__shortcut / .menu__chevron
  7. Group + label, separator — .menu__group[role=group], .menu__group-label, hr.menu__separator

Examples

Live demos open real popovers (top layer, light dismiss, Esc — no JavaScript needed to open or close). js/menu.js adds roving focus, typeahead, submenu arrows and checkable items. Frozen previews are inert copies of the open surface. States marked hover, focus-visible and active are frozen with .is-hover, .is-focus-visible, .is-active. Those classes share their rule with the real pseudo-class, so what you see is exactly what users get. Never use them in product code.

API

HookValuesPurpose
.menublock classPopover surface; role="menu"
.menu--submodifierSubmenu, opens inline-end
.menu--staticdocs-only modifierIn-flow preview of an open menu
.menu__item, .menu__item--dangerpart / modifierItem, destructive item
.menu__icon | __check | __label | __shortcut | __chevronpartItem content
.menu__group, .menu__group-label, .menu__separatorpartGrouping
.menu-trigger__chevronpart (trigger)Rotates when aria-expanded="true"
aria-checkedattributeCheckable item state
aria-disabled="true"attributeUnavailable, still focusable
menu-selecteventFired on the item: detail { item, value, checked }
init(root)JS (js/menu.js)Enhances every [aria-haspopup=menu][aria-controls]

Do and don't

Do group related actions and put destructive ones last.
Don't use a menu for site navigation — use links in a nav.

Accessibility

Keyboard interaction
KeyBehavior
Enter / Space / ↓ (trigger)Opens and focuses the first item
↑ (trigger)Opens and focuses the last item
↓ / ↑Next / previous item (wraps)
Home / EndFirst / last item
Letter keysTypeahead to the next item starting with those letters
Enter / Space (item)Runs the action and closes; toggles checkable items
→ / ←Open / close a submenu (mirrored in RTL)
EscCloses the current level; focus returns to its trigger
TabCloses the whole menu and moves on

Tokens

Custom propertyPurpose
--color-elevation-surface-overlay, --overlay-radius, --overlay-shadowSurface
--z-dropdownStacking (top layer when open as a popover)
--size-control-md | -smItem height (comfortable / compact)
--color-action-ghost-bg-hoverHighlighted item
--color-feedback-danger-fg | -bgDestructive item
--color-text-disabledDisabled item
--color-selected-fgCheck mark
--motion-duration-fast, --motion-easing-enterOpen animation (skipped with reduced motion)