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.
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.
Share Improve this question edited Oct 18, 2017 at 11:15 Vega 28.7k28 gold badges120 silver badges145 bronze badges asked Oct 16, 2017 at 16:40 user8770372user8770372 3- Adding the classnames won't do anything. You need to add corresponding css to apply those styles. – Will Howell Commented Oct 16, 2017 at 17:36
- I tried color="primary" but it did nothing – user8770372 Commented Oct 16, 2017 at 20:44
- 1 Angular Material doesn't provide generic classes for behavior like that. Check out material.angular.io/guide/theming-your-ponents – Will Howell Commented Oct 16, 2017 at 22:01
1 Answer
Reset to default 6There 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./a/46760925/6053654