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-button has just hardcoded 40px/40px size.
<button mat-icon-button color="primary"> <mat-icon class="material-icons">play_circle_filled</mat-icon> </button>
Since Angular Material uses 'Material Icons' Font-Family, the icon size depends on font-size. Therefore, if you want to modify the size of the icon then you change its font-size in your CSS file. You have to set the width and height too. After setting width and height to a value less that 24px, it looked awkward.
mat-icon-button. Circular button with a transparent background, meant to contain an icon. mat-fab.
Use NgStyle directive. You have two options to change the color of a mat-icon . You can use the color attribute which will use the value specified in your theme. It only accepts three attributes: "primary" , "accent" or "warn" .
Override the font size of mat-icon using either of the options. (I changed md- to mat- for the newest AM version)
.mat-icon{ height:48px !important; width:48px !important; font-size:48px !important; }
Demo
HTML:
<button mat-button> <mat-icon class="material-icons">play_circle_filled</mat-icon> </button>
CSS
::ng-deep .mat-icon{ height:48px !important; width:48px !important; font-size:48px !important; }
Check out the Demo
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
styles.css
.mat-icon{ height:48px !important; width:48px !important; font-size:48px !important; }
Demo
HTML:
<button mat-button> <mat-icon style=" height:48px !important; width:48px !important; font-size:48px !important;" class="material-icons">play_circle_filled</mat-icon> </button>
Demo
With Angular 8, resizing worked for me with:
.small-icon-button { width: 24px !important; height: 24px !important; line-height: 24px !important; .mat-icon { width: 16px !important; height: 16px !important; line-height: 16px !important; } .material-icons { font-size: 16px !important; } }
No ::ng-deep
required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With