One other possible option, if you want to have the option to scale images to any font size up to a maximum (e.g. 300px), the following scss loop would work;
@for $i from 1 through 300{
.iconsize-#{$i}{
font-size: $i+unquote('px') !important;
height: $i+unquote('px') !important;
width: $i+unquote('px') !important;
};
}
If you want to set a minimum size to generate in the compiled CSS, simply change 1
above to the minimum size you'd like and likewise, to change the maximum value, change 300
to whatever maximum value you'd like.
This is particularly handy for the icons as being SVG, they will scale to the size you set (though I've had some trouble getting third-party SVG icons scaling to fit the container, but that's a different issue). If you're like me, you often need to have the majority of icons at a specific size (e.g. menu icons) with some icons being larger (e.g. decorative elements). This loop allows you to easily test different sizes of font up to any size at 1px increments until you find a size that works for you.
What does this do?
When your SCSS is compiled to CSS, it will output a loop with the relevant classes from 1 to 300.
How do I use it?
To use, simply add the .iconsize-[x]
class to your mat-icon
;
<mat-icon class="iconsize-45">show_chart</mat-icon>
This example will set the icon to be 45px width and height.