0
votes

I am new in to the angular material. I want to change a theme when a user click on one of the two available options: 1] Dark Theme 2] Light Theme

enter image description here

So when user select Dark Theme / Light Theme then it will change component color(mat-card, mat-toolbar, mat-sidenav-container etc.) as well as font color.

1
There are multiple posts on SO regarding this. Check this post and the according stackblitz here.Fabian Küng
@FabianKung thanks for your response. I checked provided reference but i did't found how to change mat-card bg color and all. So if you know that can you please update the hint or code here, it will really useful to me and other also.Mahesh Sandhanshiv
I have added a mat-card from the Angular Material documentation to the stackblitz I linked in the comments here. As you can see when you change the theme via the buttons, the background color of the mat-card also changes. Maybe it is best if you post your code and what you have tried so far.Fabian Küng

1 Answers

0
votes

For those looking for the solution, check this post regarding switching themes on the fly in general and the stackblitz implementation of the same here.

Also shows that it works with mat-card as asked in this question.