k.vincent k.vincent - 11 months ago 123
Sass (Sass) Question

Ho to use angular theme for all Markup elements?

Is it possible to use Angular Material theme for text and other HTML elements such text, header, links etc. ?

I would like to use something like following:

<h2 color="'primary'">Text to be colored</h2>


I have been searching and found this posting e.g. Get Material 2 theme color scheme/palette for other elements, but it seems to be too much and I also won't agree to use just
scss
files instead of
css
.

Is there an simpler way to achieve this? For instance adding extra definition for the other elements in
theme.scss
?

Answer Source

You can use a class to set the colour in your styles:

<h2 class="app-primary">Primary</h2>

This method assumes that you have a custom theme:

$app-primary: mat-palette($mat-indigo);
// ...

.app-primary {
    color: mat-color($app-primary);
}

Or:

.app-primary {
    /* Insert hard-coded value here */
    color: #3F51B5;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download