items
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.
Example
menubar.items = [
{
text: 'File',
className: 'file',
children: [
{text: 'Open', className: 'file open'}
{text: 'Auto Save', checked: true},
]
},
{component: 'hr'},
{
text: 'Edit',
children: [
{text: 'Undo', disabled: true},
{text: 'Redo'}
]
},
{text: 'Help'}
];Disabled items
When disabled, menu bar items are rendered as "dimmed".
By default, disabled items are not focusable and don't react to hover. As a result, they are hidden from assistive technologies, and it's not possible to show a tooltip to explain why they are disabled. This can be addressed by enabling several feature flags, which makes disabled items focusable and hoverable, while still preventing them from being activated:
// Allow focus and hover interactions with disabled menu bar root items (buttons)
window.Vaadin.featureFlags.accessibleDisabledButtons = true;
// Allow focus and hover interactions with disabled menu bar sub-menu items
window.Vaadin.featureFlags.accessibleDisabledMenuItems = true;Both flags must be set before any menu bar is attached to the DOM.
Item tooltips
Buttons and sub-menu items can have tooltips that are shown on hover and keyboard focus. To enable them, add a slotted <vaadin-tooltip> element and set the tooltip property on each item that should have one:
<vaadin-menu-bar>
<vaadin-tooltip slot="tooltip"></vaadin-tooltip>
</vaadin-menu-bar>