MenuBarElement
<vaadin-menu-bar> is a Web Component providing a set of horizontally stacked buttons offering the user quick access to a consistent set of commands. Each button can toggle a submenu with support for additional levels of nested menus.
To create the menu bar, first add the component to the page:
<vaadin-menu-bar></vaadin-menu-bar>And then use #/elements/vaadin-menu-bar#property-items property to initialize the structure:
document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];Styling
The following shadow DOM parts are exposed for styling:
| Part name | Description |
|---|---|
container | The container wrapping menu bar buttons. |
The following state attributes are available for styling:
| Attribute | Description |
|---|---|
disabled | Set when the menu bar is disabled |
has-single-button | Set when there is only one button visible |
The following custom CSS properties are available for styling:
| Custom CSS property |
|---|
--vaadin-menu-bar-gap |
See Styling Components documentation.
Internal components
In addition to <vaadin-menu-bar> itself, the following internal components are themable:
<vaadin-menu-bar-button>- has the same API as #/elements/vaadin-button.<vaadin-menu-bar-item>- has the same API as #/elements/vaadin-item.<vaadin-menu-bar-list-box>- has the same API as #/elements/vaadin-list-box.<vaadin-menu-bar-submenu>- has the same API as #/elements/vaadin-context-menu.
The <vaadin-menu-bar-item> sub-menu elements have the following additional state attributes on top of the built-in <vaadin-item> state attributes:
| Attribute | Description |
|---|---|
expanded | Expanded parent item. |
Properties
Defines a hierarchical structure, where root level items represent menu bar buttons, and children property configures a submenu with items to be opened below the button on click, Enter, Space, Up and Down arrow keys.
If true, the submenu will open on hover (mouseover) instead of click.
If true, the buttons will be collapsed into the overflow menu starting from the "start" end of the bar instead of the "end".
If true, the top-level menu items is traversable by tab instead of arrow keys (i.e. disabling roving tabindex)