Hi,
does anybody know how can I seperate styling from code? I want to put all this styling to .css file. How can I do it? This is example from Vaadin Start.
Avatar avatar = new Avatar(user.getName());
StreamResource resource = new StreamResource("profile-pic",
() -> new ByteArrayInputStream(user.getProfilePicture()));
avatar.setImageResource(resource);
avatar.setThemeName("xsmall");
avatar.getElement().setAttribute("tabindex", "-1");
MenuBar userMenu = new MenuBar();
userMenu.setThemeName("tertiary-inline contrast");
MenuItem userName = userMenu.addItem("");
Div div = new Div();
div.add(avatar);
div.add(user.getName());
div.add(new Icon("lumo", "dropdown"));
div.getElement().getStyle().set("display", "flex");
div.getElement().getStyle().set("align-items", "center");
div.getElement().getStyle().set("gap", "var(--lumo-space-s)");
userName.add(div);
I want to separate MenuBar and Div styling.
I found that the Div is #shadow-root (https://vaadin.com/docs/latest/styling/advanced/shadow-dom-styling) Currently I am using Vaadin 23.