Change size of mat-icon-button

前端 未结 8 1452
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 04:36

How can I change mat-icon-button size? My icon has 24px now and I would like to increase that value to 48px. I use mat-icon as a button content. I also noticed that mat-icon-but

8条回答
  •  不要未来只要你来
    2021-02-05 04:57

    Override the font size of mat-icon using either of the options. (I changed md- to mat- for the newest AM version)


    ::ng-deep to reach that class deep in the host. The width and the height should be also set to adjust the backdrop size proportionally.

    HTML:

    
    

    CSS

    ::ng-deep .mat-icon{
        height:48px !important;
        width:48px !important;
        font-size:48px !important;
    }
    

    Check out the Demo


    Or, if you avoid ::ng-deep, use ViewEncapsulation.None (but use sparingly):

    Class:

    import {ViewEncapsulation} from '@angular/core';
    
    @Component({
      encapsulation: ViewEncapsulation.None
    })
    

    Then you can style directly from the component stylesheet.

    CSS:

    .mat-icon{
        height:48px !important;
        width:48px !important;
        font-size:48px !important;
    }
    

    Demo


    Or style it from the main stylesheet, styles.css:

    styles.css

    .mat-icon{
        height:48px !important;
        width:48px !important;
        font-size:48px !important;
    }
    

    Demo


    And last, but not the least solution, styling can be done inline:

    HTML:

    
    

    Demo

提交回复
热议问题