Skip to content

Menubar

Lab Available in release assets

Prototype the bounded ARIA composite keyboard model for desktop-style command sets when ordinary navigation cannot express the task.

Show code
<nav aria-label="Editor commands">
  <ul class="thin-menubar" role="menubar">
    <li>
      <a role="menuitem" href="/editor/file/" aria-haspopup="true" aria-expanded="false">File</a>
      <ul role="menu">
        <li><a role="menuitem" href="/editor/new/">New document</a></li>
        <li><a role="menuitem" href="/editor/open/">Open…</a></li>
      </ul>
    </li>
    <li><a role="menuitem" href="/editor/edit/">Edit</a></li>
    <li><button role="menuitem" type="button" aria-disabled="true">Publish unavailable</button></li>
    <li><a role="menuitem" href="/editor/help/">Help</a></li>
  </ul>
</nav>

Each authored example uses the production assets and includes copyable markup.

Anatomy

  • Named navigation fallback
  • Menubar composite
  • Roving menuitems
  • Optional submenu
  • Durable link destinations
  • Disabled state

Variants and sizes

  • Links — shown above
  • Command buttons — shown above
  • Single-level submenu — shown above

Rendered fixtures exercise authored content and constrained layouts with the same production assets.

  • Initial — shown above
  • Roving focus — shown above
  • Submenu open — shown above
  • Disabled item — shown above
  • Escape return — shown above
  • Right-to-left — shown above
  • Reconnect after morph — shown above
  • No JavaScript fallback — shown above

Interaction and keyboard behavior

Lab behavior adds roving focus, Arrow keys, Home, End, submenu entry, and Escape return. Refresh after server morphs. Authored links and expanded submenu content remain useful before enhancement.

Accessibility

Use this Lab only for a genuine composite command surface. Prefer ordinary nav links otherwise; preserve visible labels, durable href fallbacks, aria-disabled semantics, and never trap focus.

Contract
MENUBAR · APG pattern
Basis
APG Menu and Menubar for the genuine desktop command composite; explicitly Lab
Behavior guarantees
  • The one genuine menu composite; ordinary navigation, context menus, and command results keep native links, details, dialogs, or forms.
  • Synchronizes aria-haspopup, aria-expanded, and aria-controls, with horizontal menubar and vertical submenu arrow keys.
  • Skips disabled menu items, restores matching focus through refresh, and restores authored attributes on disconnect.
Evidence
  • tests/unit/library/menubar.test.ts
  • tests/unit/library/advanced-component-contracts.test.ts

API

Use ul[role=menubar].thin-menubar, direct role=menuitem descendants, and an adjacent role=menu for a bounded submenu. Call refresh after HTML-over-the-wire replacement.

Behavior tier: dependency-free

Structured host, property, and example tables are not authored for this item yet. Use the summary above and the primary example.

Fallback

Before enhancement, every link remains reachable in document order and submenu destinations remain expanded in normal flow.

Assets and dependencies

  • /foundation.css
  • /labs.css
  • /labs.js

Dependencies: None

Source: packages/ui/src/items/menubar/style.ts