Angular/material2 mat-spinner resize
Resize the Angular Material mat-spinner
through CSS scaling using transform: scale(X)
. For a doubled size spinner (aka big bertha), set X to 2:
Or explicitly specify the dimensions with width and height like a boss:
The trick is to apply these CSS rules in the specific component's CSS sticking to our version of social distancing with global style changes.
Diameter Property: The Magnifying Glass
The diameter
property takes on the role of a zoom lens. You can set the size of mat-spinner
by attributing a value directly to the element itself:
Sidenote: The spinner aka social butterfly gracefully adjusts itself to the size of its parent container, making your life easier.
Recommended: Keep it in the Stylesheets
Though inline styles may seem like a greased lightning, in the long run, they transform into silent little chaos. So, always aim for maintainable, organized styling by keeping the CSS in stylesheets.
CSS 'zoom': When scaling is having a field day
To rescale a spinner within a button without doing a Hulk on the button size, consider using the CSS zoom
property:
This subtle zoom
keeps the spinner size in check without taking any toll on the button's size or elegance.
Component-wise custom spinner sizing
Keeping the specific screen size in mind, you can custom size your spinner. Let's explore how.
Colossal or Compact: Media Queries
Opt for media queries to ensure your spinner maintains its charm on a range of screen sizes:
From the slingshot to the catapult: Progressive Enhancement
Encourage your mat-spinner
to grow with screen size. Leverage progressive enhancement to increment the spinner size gradually:
Keeping the style in style: Smart Proportions
Keeping the spinner to its surroundings' proportion promotes aesthetic and functional integrity. Too small, and it's a goner; too big, and we have King Kong in town.
Caution: UI mishaps you don't want
Flattening the Spinner
Setting width
and height
separately without the diameter
might give you a spin-top instead of a spinner; let's not squash our whirly friend.
Escaping the mat-diameter
trap
mat-diameter
might sound like a cool dude, but it's a goner. The diameter
attribute is here to stay and size your spinner as you desire.
The Container Conundrum
mat-spinner
turns into a shapeshifter when left loose, adjusting according to its parent. Keep this in mind and you've tamed the shapeshifter!
Was this article helpful?