Dynamically change less variable for dark theme in Angular


I hope it is possible. Need to dynamically change less variable for using dark theme.
The code is below:

@theme: dark;

@colors: {
  primary-violet-light: #608cef;
  primary-violet-dark: #031d58;

@primary-violet: @colors[[email protected]{theme}]; // have to be #031d58

But even it doesn’t work. The error is in the last row.

"[email protected]{theme}" have to be primary-violet-dark but it doesnt.

Didnt find solution in another topics, so if somebody have a solution for this I would be grateful for help!
Next step is to change @theme variable from app. I use Angular 12.

Source: Angular Questions

Categorized as angular, darkmode, javascript, less, variables Tagged , , , ,


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us