How to set the color of an icon in Angular Material?

后端 未结 7 1760
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 23:48

I have this, which I would assume to work, but doesn\'t:

home
         


        
7条回答
  •  执笔经年
    2021-02-05 00:09

    Here's a move that I'm using to set the color dynamically, it defaults to primary theme if the variable is undefined.

    in your component define your color

      /**Sets the button colors - Defaults to primary them color */
      @Input('buttonsColor') _buttonsColor: string
    

    in your style (sass here) - this forces the icon to use the color of it's container

    .mat-custom{
      .mat-icon, .mat-icon-button{
         color:inherit !important;
      }  
    }
    

    in your html surround your button with a div

            

提交回复
热议问题