Menubar
<div class="menubar"> <button class="menubar-trigger" type="button" popovertarget="menubar-file">File</button> <div class="dropdown-menu" id="menubar-file" popover> <button class="dropdown-menu-item" type="button"> New Tab <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">T</kbd></span> </button> <button class="dropdown-menu-item" type="button"> New Window <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">N</kbd></span> </button> <button class="dropdown-menu-item" type="button" aria-disabled="true">New Incognito Window</button>
<hr class="dropdown-menu-separator" />
<button class="dropdown-menu-item dropdown-menu-sub-trigger" type="button" popovertarget="menubar-share"> Share </button> <div class="dropdown-menu" id="menubar-share" popover> <button class="dropdown-menu-item" type="button">Email link</button> <button class="dropdown-menu-item" type="button">Messages</button> <button class="dropdown-menu-item" type="button">Notes</button> </div>
<hr class="dropdown-menu-separator" />
<button class="dropdown-menu-item" type="button"> Print… <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">P</kbd></span> </button> </div>
<button class="menubar-trigger" type="button" popovertarget="menubar-edit">Edit</button> <div class="dropdown-menu" id="menubar-edit" popover> <button class="dropdown-menu-item" type="button"> Undo <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">Z</kbd></span> </button> <button class="dropdown-menu-item" type="button"> Redo <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⇧</kbd><kbd class="kbd">⌘</kbd><kbd class="kbd">Z</kbd></span> </button> <hr class="dropdown-menu-separator" /> <button class="dropdown-menu-item" type="button">Cut</button> <button class="dropdown-menu-item" type="button">Copy</button> <button class="dropdown-menu-item" type="button">Paste</button> </div>
<button class="menubar-trigger" type="button" popovertarget="menubar-view">View</button> <div class="dropdown-menu" id="menubar-view" popover> <button class="dropdown-menu-checkbox-item" type="button" aria-checked="true" data-pk-keep-open> <span class="dropdown-menu-item-indicator"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M20 6 9 17l-5-5"></path> </svg> </span> Always Show Bookmarks Bar </button> <button class="dropdown-menu-checkbox-item" type="button" data-pk-keep-open> <span class="dropdown-menu-item-indicator"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M20 6 9 17l-5-5"></path> </svg> </span> Always Show Full URLs </button> <hr class="dropdown-menu-separator" /> <button class="dropdown-menu-item" type="button"> Reload <span class="dropdown-menu-shortcut kbd-group"><kbd class="kbd">⌘</kbd><kbd class="kbd">R</kbd></span> </button> </div>
<button class="menubar-trigger" type="button" popovertarget="menubar-profiles">Profiles</button> <div class="dropdown-menu" id="menubar-profiles" popover> <div class="dropdown-menu-radio-group"> <button class="dropdown-menu-radio-item" type="button" aria-checked="true" data-value="ada"> <span class="dropdown-menu-item-indicator"><span></span></span> Ada Lovelace </button> <button class="dropdown-menu-radio-item" type="button" data-value="grace"> <span class="dropdown-menu-item-indicator"><span></span></span> Grace Hopper </button> </div> <hr class="dropdown-menu-separator" /> <button class="dropdown-menu-item" type="button">Edit…</button> </div></div><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.
| Class | Part |
|---|---|
.menubar | The bar |
.menubar-trigger | One 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.
What the bar adds
Section titled “What the bar adds”| Key | Action |
|---|---|
| Tab | Reaches 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.
Accessibility
Section titled “Accessibility”- The bar is a
menubar, each trigger amenuitem— 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.