Menubar
vig-menubar
import { Menubar } from '@vigdx/ui/menu';Basic
items ; each one's items is its menu, with the same entries as vig-menu : submenus, separators, shortcuts, groups and checkable items. A top-level item without items acts directly. selected emits every activated item, and each item's run runs too.
Collapsing on narrow layouts
collapse ( sm 30rem by default, md 40rem, lg 48rem, or never ), it shows one Menu button that opens the same items, the top-level menus as submenus. It is a CSS container query, so a server-rendered page shows the right form before any script runs. The bar fills the space it gets ( flex: 1 in a flex row); inside a shrink-to-fit parent, give it a width.
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="menu"][data-part="menubar"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="menu"]
| Part | Element | data-state |
|---|---|---|
menubar | role="menubar" row of top-level items. | — |
menubar-item | <button> or <a> ( role="menuitem" ). | open, closed |
menubar-trigger | collapse ). | — |
panel | role="menu" panel (also each submenu), in the overlay container. | — |
item | <a> or <button> : open / closed with a submenu, checked / unchecked when checkable. | open, closed, checked, unchecked |
icon | — | |
label | — | |
indicator | — | |
shortcut | <kbd> of an item's shortcut . | — |
submenu-indicator | — | |
group | role="group" of items sharing a group heading. | — |
group-heading | — | |
separator | <hr> . | — |
| Attribute | Meaning |
|---|---|
data-opening | <dialog> ) while its entrance transition plays; removed once it settles (2s at most). Style the entrance with data-opening: utilities. |
data-closing | data-closing: utilities. |
Accessibility
- Follows the WAI-ARIA APG menubar pattern: a
role="menubar"named bylabels.ariaLabel(“Application menu” by default) ofrole="menuitem"items; those with a menu havearia-haspopup="menu"andaria-expanded, and their menu is labelled by them. - The bar is one Tab stop (a roving tab index). ArrowLeft and ArrowRight move between its items and wrap, Home and End jump, typing a letter moves to the next item starting with it; in right-to-left pages the arrows are mirrored. ArrowDown or Enter opens a menu on its first item, ArrowUp on its last.
- While a menu is open, ArrowLeft and ArrowRight close it and open the adjacent one with focus on its bar item (ArrowDown then enters it), from the bar or from inside the menu; pointing at another bar item switches to its menu, without animation. Escape closes the menu and returns to its bar item; Tab closes it and leaves the bar.
- Inside the menus everything works as in the Menu: submenus, typeahead, checkbox and radio items, and every menu closes once an item is activated.
- The collapsed form is a menu button (
aria-haspopup="menu") named bylabels.triggerLabel. - Use a menubar for application commands. For site navigation, prefer links your users Tab through, such as the Sidebar.
API
Menubar
vig-menubarApplication menu bar (File, Edit, View) following the APG menubar
pattern: one Tab stop, ArrowLeft/ArrowRight between the top-level items
(mirrored in RTL), ArrowDown opens a menu, typing jumps to an item, and
once a menu is open, the arrow keys and the pointer switch between menus.
Its menus are the same panels as vig-menu's, with submenus, groups and
checkbox and radio items. Narrower than collapse, it becomes a single
"Menu" button opening the same items, decided by CSS alone, so a
server-rendered page shows the right one from the start.
<vig-menubar [items]="menus" (selected)="log($event)" />While it plays its entrance or exit transition, the animating element
carries data-opening or data-closing (stable hooks for styling and
for waiting in tests; see the theming guide).
data-opening data-closing
| Name | Type | Default | Description |
|---|---|---|---|
collapse | MenubarCollapse | 'sm' | Bar width below which it collapses into one button. |
items | readonly MenuItem[] | [] | Top-level items; each one's |
labels | Partial<MenubarLabels> | — | Texts of the bar and its collapsed button (i18n); locale defaults. |
| Name | Payload | Description |
|---|---|---|
checkedChange | MenuCheckedChange | A checkbox or radio item was activated: update its |
selected | MenuItem | Emitted when an item is activated (its |