With this you only load your the theme-boilerplate once and change all colors using CSS-Vars in browser. This also enables to allow your user's to have a custom theme.
FullStack JavaScript Developer
Google Dev Expert for Angular - https://bit.ly/SiddAjmeraGDE
Angular Instructor on Udemy - https://www.udemy.com/course/angular-all-you-need-to-know/
Great article and example on how to create a theme-switch :)
With this way
node_modules/@angular/material/prebuilt-themes/${themeToSet}.css
I see two disadvantages:assets
to the build output (node_modules probable not exist anymore when you serve your app outside of the CLI)IMO, a better way would be to use @johannesjo Helper Library: Demo - GitHub
With this you only load your the theme-boilerplate once and change all colors using CSS-Vars in browser. This also enables to allow your user's to have a custom theme.
Hi Negue,
Good point. 😃 I did realise this issue with the approach. I'll probably cover the CSS vars approach in a future article.
Thanks a lot for the feedback 🙌🏻🙂