How to change font color of primary palette in Angular Material2?

前端 未结 3 535
旧时难觅i
旧时难觅i 2020-12-09 03:47

In the official theming documentation of Angular Material2 it states clearly the following:

In Angular Material, a theme is created by composing multi

3条回答
  •  执念已碎
    2020-12-09 04:34

    The guide is available at the documentation website located here.

    First, you define the palettes for your theme, such as $primary, $accent, $warn (in the guide they have $candy-app- prefix) and then create a $theme object:

    // Create the theme object (a Sass map containing all of the palettes).
    $theme: mat-light-theme($primary, $accent, $warn);
    

    Once we have a theme that contains all the palettes, we can get a foreground palette from it:

    $foreground: map-get($theme, foreground);
    

    From $foreground palette we can get any values based on a key, such as

    secondary-text: rgba(black, 0.54),
    

    or

    text: rgba(black, 0.87)
    

    Here's the code to retrieve the secondary-text property:

    color: mat-color($foreground, secondary-text);
    

    I switched to 2.0.0-beta.3 from 2.0.0-beta.2 and the folders structure looks different, you are right. It is now \node_modules\@angular\material\_theming.scss, _palette.scssfile is gone. You can do global search for it though: '$mat-dark-theme-background: ('

    _theming.scss has all the colors, maps and all the functions, like mat-color

提交回复
热议问题