How to Create Multiple Themes for Your Angular Project

Nowadays, many of the web applications are offering multiple color themes for their users. The recent example we can take is StackOverflow.

Many of the developers were waiting for their favorite dark mode for their favorite place on the internet. I have also tried to do so in one of my angular projects. Today I’ll tell you about it.

It’s all the magic of CSS variable property. CSS has provided us a feature called var(), which allows us to runtime change properties of our CSS elements. The var() function in CSS is used to insert a value for the custom property.


var( custom_property, value )

where :


is the name of custom property must start with two dashes (–), which is mandatory.


is the optional parameter, which is used if the custom property is invalid. You can use this magic with your SCSS file and any non-angular project where CSS or SCSS is used.

Check Out What It Takes To Build A Successful App Here

Deep Dive-

Let’s start with coding in Angular.

Create a project in Angular, generate components that you want and design your HTML. I have created an Interface because of that I can create as well as export themes. You can define as many themes as you want. In my case, I have ‘Default theme’, ‘Light Theme’, and a ‘Dark Theme’.

Create an interface called Theme and export a class as the default theme of your component. Also, create your favorite themes.

NOTE– In your code, you can create a Module for all theme-related files, it will be a better coding practice & project structuring.

Now, In your component’s CSS file, use the magic of var(). Create CSS class and define element properties as –

background-color: var(--button-bg-color);
border-color: var(--button-border-color);
color: var(--button-text-color);

Create a service, import the theme definitions. Define methods to activate your theme.

setDefaultTheme(): void {
setDarkTheme(): void {
setLightTheme(): void {

In the setActiveTheme() method, you have to write a logic that will update the properties of CSS class as below –

setActiveTheme(theme: Theme): void { = theme;
Object.keys( => {

And yes, we are ready for it. To change the themes use the components & call the needed method of theme service. I assume you can do that. You can find this code in GitHub repo given below.

We Built Virtual Mentorship Platform For Knowledge Seekers

Default Theme –

Default Theme of CSS

Light Theme –

Light Theme of CSS

Dark Theme –

You can check the live demo – Click Here


Hire Angularjs Developers With Flexible Hiring Models for Your Angular Projects.


Tech Expert

I love building things and learning new stuff. Enjoying journey for the last few years as a software developer and creating better things. Industry experienced MEAN Stack Developer, Full Stack Developer, and BI Developer.

Get in touch for a detailed discussion.

Hear From Our 100+ Customers

Mindbowser helped us build an awesome iOS app to bring balance to people’s lives.


We had very close go live timeline and MindBowser team got us live a month before.

Shaz Khan
CEO, BuyNow WorldWide

They were a very responsive team! Extremely easy to communicate and work with!

Kristen M.
Founder & CEO, TotTech

We’ve had very little-to-no hiccups at all—it’s been a really pleasurable experience.

Chacko Thomas
Co-Founder, TEAM8s

Mindbowser is one of the reasons that our app is successful. These guys have been a great team.

Dave Dubier
Founder & CEO, MangoMirror

Mindbowser was very helpful with explaining the development process and started quickly on the project.

Hieu Le
Executive Director of Product Development, Innovation Lab

The greatest benefit we got from Mindbowser is the expertise. Their team has developed apps in all different industries with all types of social proofs.

Alex Gobel
Co-Founder, Vesica

Mindbowser is professional, efficient and thorough. 

MacKenzie R
Consultant at XPRIZE

Very committed, they create beautiful apps and are very benevolent. They have brilliant Ideas.

Laurie Mastrogiani
Founder, S.T.A.R.S of Wellness

MindBowser was great; they listened to us a lot and helped us hone in on the actual idea of the app.” “They had put together fantastic wireframes for us.

Bennet Gillogly
Co-Founder, Flat Earth

They're very tech-savvy, yet humble.

Uma Nidmarty
CEO, GS Advisorate, Inc.

Ayush was responsive and paired me with the best team member possible, to complete my complex vision and project. Could not be happier.

Katie Taylor
Founder, Child Life On Call

As a founder of a budding start-up, it has been a great experience working with Mindbower Inc under Ayush's leadership for our online digital platform design and development activity.

Radhika Kotwal
Founder of Courtyardly

The team from Mindbowser stayed on task, asked the right questions, and completed the required tasks in a timely fashion! Strong work team!

Michael Wright
Chief Executive Officer, SDOH2Health LLC

They are focused, patient and; they are innovative. Please give them a shot if you are looking for someone to partner with, you can go along with Mindbowser.

David Cain
CEO, thirty2give

We are a small non-profit on a budget and they were able to deliver their work at our prescribed budgets. Their team always met their objectives and I'm very happy with the end result. Thank you, Mindbowser team!!

Bart Mendel
Founder, Mindworks