Skip to content

Menubar

<div class="menubar">
<button class="menubar-trigger" type="button" popovertarget="file-menu">File</button>
<div class="dropdown-menu" id="file-menu" popover></div>
<button class="menubar-trigger" type="button" popovertarget="edit-menu">Edit</button>
<div class="dropdown-menu" id="edit-menu" popover></div>
</div>

The panels are dropdown menus — same classes, same items, same keyboard. The bar adds what makes it a bar: one stop in the tab order, arrows between menus, and menus that swap as the pointer crosses once any of them is open.

ClassPart
.menubarThe bar
.menubar-triggerOne menu’s button

Keep each panel inside the .menubar element, next to its trigger. That is what lets the bar see the keys pressed inside an open menu.

KeyAction
TabReaches the bar once, not once per menu
/ Moves between menus — and swaps them while one is open
Opens the menu under focus

Everything inside a panel — arrows, type-ahead, submenus, Escape, Tab — is the dropdown menu’s own, and is documented on its page.

Set dir="rtl" on the page or on any subtree — the arrow keys follow the reading direction, so Left moves forward. See the button page for a live example.

  • The bar is a menubar, each trigger a menuitem — applied for you, along with the roving tab order.
  • One stop in the tab order. Tab reaches the bar and leaves it; arrows move within. A bar of six menus that costs six tab stops is the mistake this pattern exists to avoid.
  • A menu opened from the keyboard focuses its first item, and Escape returns focus to the trigger it came from.
  • Commands need a home outside the bar. On a phone the bar is cramped and its menus are the only route to those actions — check they are reachable another way.