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>
Here is an example using scss defined in the styles.scss to get round any encapsulation issues (defining it in a custom theme will also do the same). There is an added level of specificity to avoid using !important.
Here is the Stackblitz for it.
html
style.scss
With Angular 8, resizing worked for me with:
No
::ng-deep
required.above code working perfectly in angular2
In your component scss file (assuming sass):
You can change to whatever sizes you want for both the button and the icon. If they are both set to 48 that will not have any spacing around the icon. You may want to increase the button size to something like 64.
In your html:
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
Check out the Demo
Or, if you avoid
::ng-deep
, useViewEncapsulation.None
(but use sparingly):Class:
Then you can style directly from the component stylesheet.
CSS:
Demo
Or style it from the main stylesheet, styles.css:
styles.css
Demo
And last, but not the least solution, styling can be done inline:
HTML:
Demo