why do vaadin 14 add different styles to elements of the same type?

The preferred way to do this is to utilize theme attributes. It allows you to add additional selector in CSS rule like follows

:host([theme~="secondary-menu"]) ... {

And in Java code you need to set the value of the theme attribute for the component itself.

menuBar.getElement().setAttribute("theme", "secondary-menu");

This theme attribute value is propagated to the sub-components also. Which makes possible for example to style TextField of the ComboBox or DatePicker without styling all the possible TextFields.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top