Menu Bar Styling
Style Variants
The following variants are supported by the Menu Bar:
| Variant | Description | Supported by |
|---|---|---|
| Corresponds to the primary button variant. Recommended for drop-down buttons use case | Aura, Lumo |
| Corresponds to the tertiary button variant, omitting the background color | Aura, Lumo |
| Corresponds to the tertiary inline button variant | Lumo |
| Reduces the size of menu bar buttons | Lumo |
| Increases the size of menu bar buttons | Lumo |
| Recommended as an additional color option | Lumo |
| Recommended for icon only menu bar buttons | Lumo |
| Used to visually indicate buttons with sub-menu | Lumo |
| Used to align buttons to the end of the menu bar | Aura, Lumo |
|
Tip
|
Customize Default Menu Button Styles
The standard Menu Button styles can be adjusted using the Button style properties. These variants should be used only to differentiate special instances of the component.
|
Alignment
Top-level items are aligned by default to the start of the Menu Bar. Use instead the end-aligned theme variant to align them to the end.
Source code
MenuBarRightAligned.java
menu-bar-right-aligned.tsx
menu-bar-right-aligned.ts
Styling Menu Items
Individual menu items can be styled by applying custom class names to them, and writing CSS style blocks targeting those class names. Notice that root-level menu items in the Menu Bar are wrapped in vaadin-menu-bar-button elements, which inherit the class names from the items within them.
Source code
MenuBarClassName.java
menu-bar-class-name.css
menu-bar-class-name.css
menu-bar-class-name.tsx
menu-bar-class-name.css
menu-bar-class-name.css
menu-bar-class-name.ts
menu-bar-class-name.css
menu-bar-class-name.css
CSS Selectors
The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the Styling documentation for more details on how to style components.
- Root element
-
vaadin-menu-bar
Buttons
- Button element
-
vaadin-menu-bar-button - Button text
-
vaadin-menu-bar-button::part(label) - Hovered button
-
vaadin-menu-bar-button:hover - Focused button
-
vaadin-menu-bar-button[focused] - Disabled button
-
vaadin-menu-bar-button[disabled] - Button with a menu
-
vaadin-menu-bar-button[aria-haspopup] - Button with opened menu
-
vaadin-menu-bar-button[expanded] - Overflow button
-
vaadin-menu-bar-button[slot="overflow"] - Overflow button icon
-
vaadin-menu-bar-button[slot="overflow"] > [aria-hidden] - Button rich content wrapper
-
vaadin-menu-bar-button> vaadin-menu-bar-item - Button icon
-
vaadin-menu-bar-button> vaadin-menu-bar-item > vaadin-icon
Sub-Menu
- Sub-menu element
-
vaadin-menu-bar-submenu - Sub-menu background
-
vaadin-menu-bar-submenu::part(overlay) - Sub-menu content wrapper
-
vaadin-menu-submenu::part(content) - Nested sub-menu
-
vaadin-menu-bar-submenu[modeless]
Items
- Item element
-
vaadin-menu-bar-item - Item content wrapper
-
vaadin-menu-bar-item::part(content) - Checked item indicator
-
vaadin-menu-bar-item[menu-item-checked]::part(checkmark) - Checked item indicator icon
-
vaadin-menu-bar-item[menu-item-checked]::part(checkmark)::before - Submenu indicator icon
-
vaadin-menu-bar-item::after - Separator element
-
vaadin-menu-bar-submenu[role="separator"]
Item States
- Hovered item
-
vaadin-menu-bar-item:hover - Focused item
-
vaadin-menu-bar-item[focused] - Disabled item
-
vaadin-menu-bar-item[disabled] - Item with a nested sub-menu
-
vaadin-menu-bar-item[aria-haspopup] - Item with expanded sub-menu
-
vaadin-menu-bar-item[expanded] - Checked item
-
vaadin-menu-bar-item[menu-item-checked]