If I have two theme folders my-app-light and my-app-dark.
How can I toggle between them through the app? V24
You can’t. Theme can only be one per application at runtime.
You are looking for a variant - see Toggle between light and dark theme in Vaadin Flow | Vaadin
You need to have a single theme folder where the colors for both (or multiple) themes, to achieve to switching themes during runtime. If not you need to choose the theme before building the app.
Rely on the Lumo Style Properties.
I mostly go to the Lumo Theme Editor and create my themes there. Then you can copy the css to e.g. your styles.css
and have something like this:
html {
/* light theme variables */
--lumo-primary-color: red;
}
[theme~="dark"] {
/* dark theme */
--lumo-primary-color: white;
}
[theme~="pink"] {
/* pink theme */
--lumo-primary-color: pink;
}
Thank you for this.
But are there any work-arounds to achieve what I mentioned?
Do you mean something like Option 2 of this post, that Christian mentioned above?
Or do you mean that: https://vaadin.com/docs/latest/styling/application-theme#applying-a-theme
I meant something like changing
<link rel="stylesheet" href="themes/default/styles.css" />
from some view in the app
No. Only your active theme is compiled into the application.
This should be of help: https://vaadin.com/docs/latest/styling/advanced/runtime-theme-switching
Thank you everyone for clarifying.