-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to set dark theme #3675
Comments
Current way of using the dark variant: @Theme(Lumo.class)
public class RootLayout extends Div implements PageConfigurator, RouterLayout {
@Override
public void configurePage(InitialPageSettings settings) {
settings.getUi().getElement().setAttribute("theme", "dark");
}
...
} I think we should #ffs this to make it even easier, a proposal: @Theme(Lumo.class, variant = Lumo.DARK)
public class RootLayout extends Div implements RouterLayout {
} Here variant would be a just a If there would be more complex variants, there could be another parameter, like |
Another alternative would be a meta annotation approach, allowing each theme do define their own annotation that can have any strongly typed parameters. In that case, the application code could be
where We could also see dark Lumo as a theme of its own, e.g. either |
The problem with the current workaround that @pleku suggested above is that it runs too late and results in the light variant being shown first, and then a flash as the theme variant changes. Whichever alternative we go with needs to send the variant info with the initial server response so we avoid flashing. |
Decided to go for: @Theme(Lumo.class, variant = Lumo.DARK)
public class RootLayout extends Div implements RouterLayout {
} Here variant would be a just a We should update the documentation for using component themes about the variant usage. Also update the disclaimer that you cannot mix different variants together. |
I want to be able to set the dark theme variant for my entire application. Setting the theme attribute on the main layout doesn't change the
body
background color.The text was updated successfully, but these errors were encountered: