0

I use Angular Material 18 in my little pet project and have custom theme defined. I can access the variable and (for example) set it as a text:color like so:

.some-selector { color: mat.get-theme-color(material-theme.$my-theme, "primary", 50); } 

This does work, but it feels so ugly to have that ~60 characters in multiple places all around my application. Also, if I do this in a component I'd have to first add these lines as well:

@use '@angular/material' as mat; @use '../../../styles/material-theme'; 

Isn't there a better way? What I want is to define some sort of alias (e.g. custom property in CSS) and just use that one. Like so:

html { --my-alias: mat.get-theme-color(material-theme.$my-theme, "primary", 50); } // in all other places .some-selector { color: var(--my-alias); } 

This simply does not work. What am I missing here?

1

1 Answer 1

2

You should add braces:

--my-alias: #{mat.get-theme-color(material-theme.$my-theme, primary, 50)}; 
Sign up to request clarification or add additional context in comments.

1 Comment

aah, finally. Thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.