Menubar
hc-menubar is the desktop application menu bar pattern: a horizontal
row of menu buttons (File / Edit / View …), each opening an
hc-menu dropdown. It is a thin
layer over the existing menu machinery — installMenu() owns the dropdown
internals (ARIA, in-menu keyboard, submenus); installMenubar() adds the bar
navigation.
Basic example
Section titled “Basic example”<div class="hc-menubar" role="menubar" aria-label="Application"> <button class="hc-menubar__item" role="menuitem" type="button" popovertarget="mb-file" id="mb-file-t">File</button> <div class="hc-menu" id="mb-file" popover role="menu" aria-labelledby="mb-file-t"> <button class="hc-menu__item" role="menuitem" type="button">New</button> <button class="hc-menu__item" role="menuitem" type="button">Open…</button> </div>
<button class="hc-menubar__item" role="menuitem" type="button" popovertarget="mb-edit" id="mb-edit-t">Edit</button> <div class="hc-menu" id="mb-edit" popover role="menu" aria-labelledby="mb-edit-t"> <button class="hc-menu__item" role="menuitem" type="button">Undo</button> </div></div>import { installMenu, installMenubar } from '@hypermedia-components/core';installMenu(); // dropdown internalsinstallMenubar(); // the bar navigationEach top button is a role="menuitem" that targets its dropdown with
popovertarget; the dropdowns are ordinary hc-menu popovers (so they get
submenus, checkbox/radio items, and the hc:menuselect event for free).
Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
← / → | Move between top items (mirrored in RTL). Wraps at the ends. |
Home / End | First / last top item. |
↓ / Enter / Space | Open the focused menu (↓ focuses the first item). |
↑ | Open the focused menu at its last item. |
← / → (menu open) | Switch to the adjacent menu and open it. |
Esc | Close the menu, returning focus to its top item. |
A submenu parent still opens its submenu on → (the menubar defers to the
submenu machinery), so nested menus keep working.
Accessibility
Section titled “Accessibility”- The bar is
role="menubar"with anaria-label; each top button is arole="menuitem"and getsaria-haspopup="menu"/aria-expandedwired byinstallMenu(). - The bar is a single Tab stop (roving tabindex); arrow keys move within it, matching the WAI-ARIA APG menubar pattern.
- Label each dropdown (
aria-labelledbypointing at its button, oraria-label) so the open menu has an accessible name.
Theming tokens
Section titled “Theming tokens”| Token path | Purpose |
|---|---|
menubar.gap | Gap between top items. |
menubar.padding-x / -y | Bar padding. |
menubar.bg | Bar background. |
menubar.border | Bar border. |
menubar.radius | Bar corner radius. |
menubar.item-padding-x / -y | Top item padding. |
menubar.item-radius | Top item radius. |
menubar.item-fg | Top item text color. |
menubar.item-hover-bg | Top item hover / open background. |
CSS variables
Section titled “CSS variables”Show the generated CSS variables
--hc-menubar-gap | -padding-x | -padding-y | -bg | -border | -radius--hc-menubar-item-padding-x | -item-padding-y | -item-radius | -item-fg | -item-hover-bg