menu

Semantic container for toolbar buttons and context menu patterns. Provides structure for groups of interactive commands.

Description

The <menu> element represents a group of commands or options. It is semantically equivalent to <ul> but signals to assistive technologies that the items represent commands rather than list content.

In Vanilla Breeze, <menu> is styled as a flexible container with variants for toolbars, context menus, vertical menus, and icon button groups.

When to Use

  • Toolbars: Groups of action buttons in editors or applications
  • Context menus: Dropdown menus with actions
  • Action lists: Vertical lists of commands
  • Button groups: Related buttons that function as a unit
  • Filter controls: Pill-style toggles for filtering content

When Not to Use

  • For navigation links — use <nav>
  • For content lists — use <ul> or <ol>
  • For dropdown selection — use <select>
  • For full dropdown components — use <drop-down>

Variants

Default Menu

The default menu displays as a horizontal flexbox container.

.toolbar

Horizontal toolbar with background and contained button styling.

.context

Dropdown-style context menu with separators. Works with both buttons and links.

.vertical

Vertical menu layout for sidebar or dropdown patterns.

.icons

Icon-only toolbar with square icon buttons.

.pills

Pill-shaped buttons for filter or toggle patterns.

Styling

CSS Implementation

Variant Classes Summary

Class Description
.toolbar Horizontal toolbar with background container
.context Dropdown-style menu with shadow and separators
.vertical Vertical stacking layout
.icons Square icon-only buttons
.pills Pill-shaped button items
.compact Reduced spacing and font size

Menu Separators

Use role="separator" on list items to create visual dividers in context menus.

Accessibility

Semantic Structure

The menu element conveys that its items are commands. Each <li> should contain a <button> or <a> for proper interaction.

ARIA Roles

  • role="separator" — Marks visual dividers between groups of items
  • aria-label — Required on icon-only buttons to describe the action
  • aria-disabled — For non-functional menu items

Icon Buttons

When using icon-only buttons, always include an aria-label for screen reader users:

Keyboard Navigation

Key Action
Tab Move focus between menu buttons
Enter / Space Activate focused button

Related

  • <button> — Primary interactive element inside menu items
  • <li> — List item (required child)
  • <nav> — For navigation links (not commands)
  • <ul> — For non-command list content
  • <dialog> — For modal menus or action sheets
  • <context-menu> — Full-featured context menu web component
  • <drop-down> — Dropdown menu web component

Browser Support

The <menu> element is supported in all browsers. Its semantic meaning is recognized by screen readers, though the element renders identically to <ul> by default.