Brian Sheely:
Thanks for all the help, and sorry for all the questions.
No worries, happy to try to help.
I understand the basics of CSS, but it almost seems that most of the basic rules of CSS don’t apply to Vaadin. The CSS seems extremely convoluted.
It does apply, but the difficulty is usually finding the right component to theme. We’re aware that it’s an issue for devs, and we’re working on improving the documentation (and other tools) to help make theming easier.
So far, I have a menu bar with 2 buttons and one of the buttons has a sub-menu. The first code sample that you posted removes the background color from both buttons. It also removes the hover background color on the button with no sub-menu, but doesn’t remove the background color on hover on the other button.
This should make the background transparent by default and on hover as well:
@CssImport(value = "./styles/menu-bar-button.css", themeFor = "vaadin-menu-bar-button")
:host {
background-color: transparent;
}
:host(:hover)::before {
opacity: 0;
}
It won’t affect items in the overlay/popup as they are not vaadin-menu-bar-button
elements.
The second code sample that you posted removed the background color on hover for all of the sub-menu items. Given the fact that both menu buttons are elements of type vaadin-menu-bar-button, why does the CSS behave differently on the 2 buttons?
The items you see in the overlay/popup are vaadin-context-menu-item
elements. Their hover style is actually set by vaadin-context-menu-list-box
. Source code: https://github.com/vaadin/vaadin-context-menu/blob/master/theme/lumo/vaadin-context-menu-styles.html#L70.
So, if you wish to change that you need to do the following:
@CssImport(value = "./styles/context-menu-list-box.css", themeFor = "vaadin-context-menu-list-box")
context-menu-list-box.css
:
[part="items"]
::slotted(.vaadin-menu-item:hover:not([disabled]
)),
[part="items"]
::slotted(.vaadin-menu-item[expanded]
:not([disabled]
)) {
background-color: ...;
}