You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not properly documented yet, but there's a use-system-variables in the color and typography fields of M3 themes. If you set it to true, you'll be able to theme dynamically by changing a ~10 CSS variables at runtime. Here's how to pass it: https://github.com/angular/components/blob/main/src/dev-app/theme-m3.scss#L15
Below are all the possible ones. You don't need to provide all of them, e.g. if you don't set use-system-variables for the typography, you can skip the whole typography section. We also have the mat.system-level-colors and mat.system-level-typography mixins that you can use to generate the values from a theme.
That's awesome, they are the same as material-web style tokens with just different prefix --md-sys <-> --sys. With material-color-utilities npm package, it should be super simple to provide these.
Is there a way to do this at component level easily.
The double inheritance problem, Why this wont work for individual components? - lit playground
Also this is a very common use-case, suppose i want to display multiple color schemes option at once to a user.
PRACTICAL NEED:
Suppose I make a theme service that applies the dynamically generated css vars like --md-sys-* etc to the host component where the service is provided, the service depends on a minimal injection token SOURCE_COLOR for generating the color scheme. Now the problem arises because even though every thing should work in theory, as it works with lit based material components (which are now on maintenance mode, and the docs reads "use angular material for angular framework" ), but due to inherited css vars used in angular-material components, there is no way to make such a thing work with angular-material. Any thoughts ?
At component level angular material uses lots of internal variables. But, with Angular Material 18, team have introduced overrides API, you can use it like below, of course, for runtime changes you will still need to figure out all of CSS (--mat-* and --mdc-*) the variables.
button {
@includemat.button-overrides((
ripple-color: red
))
}
Activity
crisbeto commentedon May 23, 2024
It's not properly documented yet, but there's a
use-system-variablesin thecolorandtypographyfields of M3 themes. If you set it totrue, you'll be able to theme dynamically by changing a ~10 CSS variables at runtime. Here's how to pass it: https://github.com/angular/components/blob/main/src/dev-app/theme-m3.scss#L15tanishqmanuja commentedon May 23, 2024
Thanks, this is exactly what I needed. Can you also provide a link to find what CSS Vars are used ?
crisbeto commentedon May 23, 2024
Below are all the possible ones. You don't need to provide all of them, e.g. if you don't set
use-system-variablesfor the typography, you can skip the whole typography section. We also have themat.system-level-colorsandmat.system-level-typographymixins that you can use to generate the values from a theme.tanishqmanuja commentedon May 23, 2024
That's awesome, they are the same as material-web style tokens with just different prefix --md-sys <-> --sys. With material-color-utilities npm package, it should be super simple to provide these.
tanishqmanuja commentedon May 23, 2024
AFAIK material-color-utilities don't inject surface tokens as of now, here's a snippet if anyone needs it.
Change the prefix as per requirement 🤞🏻
konstantindenerz commentedon Jul 9, 2024
There is a new option to configure the prefix of system variables.
Read more about this in my article, which includes a live demo: https://konstantin-denerz.com/angular-material-3-theming-design-tokens-and-system-variables/
tanishqmanuja commentedon Jul 10, 2024
Offtopic - Your site looks really amazing, I have mostly seen bottom navs (on mobile view) with icons but your text based bottom nav is 🔥
tanishqmanuja commentedon Aug 10, 2024
First attempt after reading @konstantindenerz article https://github.com/tanishqmanuja/demo.ng-material-dynamic-theme
Is this inline with the best practices suggested by angular-material ?
PS:
I am still confused about how to inject typography tokens
shhdharmen commentedon Sep 3, 2024
For one of my article, I used
applyThemefrom@material/material-color-utilities, and it generated all the needed colors. You can read the article with demo at https://angular-material.dev/articles/angular-material-theming-css-varstanishqmanuja commentedon Sep 13, 2024
Is there a way to do this at component level easily.
The double inheritance problem, Why this wont work for individual components? - lit playground
Also this is a very common use-case, suppose i want to display multiple color schemes option at once to a user.
PRACTICAL NEED:
Suppose I make a theme service that applies the dynamically generated css vars like --md-sys-* etc to the host component where the service is provided, the service depends on a minimal injection token SOURCE_COLOR for generating the color scheme. Now the problem arises because even though every thing should work in theory, as it works with lit based material components (which are now on maintenance mode, and the docs reads "use angular material for angular framework" ), but due to inherited css vars used in angular-material components, there is no way to make such a thing work with angular-material. Any thoughts ?
shhdharmen commentedon Sep 13, 2024
At component level angular material uses lots of internal variables. But, with Angular Material 18, team have introduced overrides API, you can use it like below, of course, for runtime changes you will still need to figure out all of CSS (--mat-* and --mdc-*) the variables.
tanishqmanuja commentedon Sep 13, 2024
figuring out all those without docs doesnt sound too good either. So that's a no for sure :(
worthy7 commentedon Jan 21, 2025
I used the generator on the latest version and I get his neutra color:
Which make shadows look silly
This is not what buttons look like on the angular component page
When inspecting, I can see it is a shade of white with some alpha applied
But that's not what is generated for me: