angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.32k stars 6.72k forks source link

docs-bug(Theming Angular Material): theme overrides vs css variables #29431

Open whynotavailable opened 1 month ago

whynotavailable commented 1 month ago

Documentation Feedback

There exists seemingly two ways to implement MDC (or MAT) tokens in scss. The first way is by directly using the variables. Such as this.

mat-toolbar {
  --mat-toolbar-container-background-color: #{mat.get-theme-color($my-theme, primary-container)};
  --mat-toolbar-container-text-color: #{mat.get-theme-color($my-theme, on-primary-container)};
}

The second way is to use the override mixins to generate the appropriate tokens (especially neat when the component uses both MDC and MAT tokens) like this.

mat-toolbar {
  @include mat.toolbar-overrides((
    container-background-color: mat.get-theme-color($my-theme, primary-container),
    container-text-color: mat.get-theme-color($my-theme, on-primary-container)
  ))
}

I can find no places where these override mixins are used or documented. Is there a preference towards one or the other?

Affected documentation page

https://material.angular.io/guide/theming#granular-customizations-with-css-custom-properties

hhaasbroek commented 1 month ago

please assign this one to me