Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material adding the primary color to a Div

I am using Angular Material 2 and I am trying to add the primary color to a div.

This is what I've done:

<div class="myDiv background-primary-color white-text">This is a Div</div>

The problem I'm having is that It's adding no color to it.


1 Answers

There is no way to use color attribute on non-material elements (and not all Angular Material elements support it). But you can follow a little hacky way: import a palette and store the color to the variable in SASS/LESS, so when you will change the current palette - this color will be changed too. Here is an awesome explanation step by step: https://stackoverflow.com/a/46760925/6053654

like image 161
Commercial Suicide Avatar answered Oct 31 '25 11:10

Commercial Suicide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!