4

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.

Vega
  • 27,856
  • 27
  • 95
  • 103

1 Answers1

6

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

P.S.
  • 15,970
  • 14
  • 62
  • 86
  • 4
    Oh cool, casually browsing and seeing a work around I posted being reposted for others :D Hope It helps OP – Cacoon Feb 16 '18 at 05:28