Angular 2 Material use lighter/darker colors on button

后端 未结 1 1588
伪装坚强ぢ
伪装坚强ぢ 2021-02-20 09:17

Is there any elegant way to use lighter/darker variants of either primary or accent colors with buttons in angular 2 material without recreating whole styling by hand?

相关标签:
1条回答
  • 2021-02-20 09:55

    If you use sass you can import material theming into your scss file and target material colors like so:

    app.component.scss

    @import '~@angular/material/theming';
    
    .buttonPrimary {
        background-color: mat-color($mat-purple, 200);
    }
    
    .buttonAccent {
        background-color: mat-color($mat-amber, A200);
    }
    

    app.component.html

    <button md-raised-button class="buttonPrimary">primary</button>
    <button md-raised-button class="buttonAccent">accent</button>
    
    0 讨论(0)
提交回复
热议问题