How do I use a material theme colors in my css in Angular2?

前端 未结 1 775
渐次进展
渐次进展 2021-01-22 03:59

Let\'s say I need to use the mat-primary color as a background of a div using a css/sass class, how do i reference it? I thought something like:

<
相关标签:
1条回答
  • 2021-01-22 04:09

    You have to first import the theme with

    @import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
    

    Then you have to define a mixin like

    @mixin primary-color($theme) {
    
      $primary: map-get($theme, primary);
    
      //Then you can use `mat-color` to get the `primary` color
      .a-class {
        background-color: mat-color($primary);
      }
    }
    

    Reference Link: Documentation

    0 讨论(0)
提交回复
热议问题