Size. To change the size of an icon, we can change the fontSize prop. The fontSize can be set to small or large . To set a custom size, we can also set the style prop with the fontSize of our choice.
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.
Material-UI Icon Size There are two ways to update the size of the icon: use the fontSize prop available on the icon or set the font-size CSS style. These are both options whether the icon is inside a button or independent of a button.
To increase the size of icons relative to its container, use icon-large , icon-2x , icon-3x , or icon-4x . Increase the icon size by using the icon-large (33% increase), icon-2x , icon-3x , or icon-4x classes. If your icons are getting chopped off on top and bottom, make sure you have sufficient line-height.
By reading the material design in github I found these useful stuff that might help you.
/* Rules for sizing the icon. */
.material-icons.md-18 { font-size: 18px; }
.material-icons.md-24 { font-size: 24px; }
.material-icons.md-36 { font-size: 36px; }
.material-icons.md-48 { font-size: 48px; }
/* Rules for using icons as black on a light background. */
.material-icons.md-dark { color: rgba(0, 0, 0, 0.54); }
.material-icons.md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); }
/* Rules for using icons as white on a dark background. */
.material-icons.md-light { color: rgba(255, 255, 255, 1); }
.material-icons.md-light.md-inactive { color: rgba(255, 255, 255, 0.3); }
From the code above, there you can simply change or override the material css icons.
Sample code:
<i class="material-icons md-18">face</i>
More details here
If I'm doing a one-off I usually just add a style= modification to the font-size in the tag. But yes long story short there's no real trick to it other than defining your own size styles to attach in css as a more permanent solution.
<i class="material-icons" style="font-size: 50px">insert_invitation</i>
if you are using scss
@mixin md-icon-size($size: 24px) {
font-size: $size;
height: $size;
width: $size;
}
.md-icon-16 {
@include md-icon-size(16px);
}
.md-icon-18 {
@include md-icon-size(18px);
}
.md-icon-24 {
@include md-icon-size(24px);
}
.md-icon-36 {
@include md-icon-size(36px);
}
You can use normal css, but must override inline styling with:
font-size: 50px !important;
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