Using Angular get-color-from-palette to Retrieve Color Values

Ole Ersoy
May 27, 2022

--

Image by Greg Montani from Pixabay

Scenario

We have defined our SASS Angular Material Accent color palette like this.

$theme-accent: mat.define-palette(mat.$cyan-palette);

And now we wish to retrieve a text color and background color from it using the default key (500).

Approach

html,body {height: 100%;background-color: mat.get-color-from-palette($theme-accent, default);color: mat.get-color-from-palette($theme-accent, default-contrast);}

For the background-color we use the default key, and for the text color we use the default-contrast key.

Playground

Use this playground to experiment with the Angular SASS Theming API.

--

--

Ole Ersoy
Ole Ersoy

Written by Ole Ersoy

Founder of Firefly Semantics Corporation

No responses yet