components icon indicating copy to clipboard operation
components copied to clipboard

Can't set height and Width of spinner since beta.12

Open argoo83 opened this issue 9 years ago • 24 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Set width and height

What is the current behavior?

<mat-spinner style="width:40px; height: 40px" color="primary"> </mat-spinner> has no effect since upgrade to beta.12

argoo83 avatar Oct 09 '17 09:10 argoo83

mat-spinner.small-spinner svg { width: 40px !important; height: 40px !important; }

Used this css to solve this.

argoo83 avatar Oct 09 '17 09:10 argoo83

I try to set the container width/height, the mat-spinner width/height and the svg width/height, did not work. It works in previous versions only setting mat-spinner (md-spinner) widht/height.

https://stackblitz.com/edit/material2-spinner-issue?file=app%2Fapp.component.scss

karlos1337 avatar Oct 09 '17 10:10 karlos1337

You can use the input parameter "diameter". (beta.12)

<mat-spinner [diameter]="40"></mat-spinner>

ghd8 avatar Oct 09 '17 11:10 ghd8

What if one is looking for something more responsive? Is there anyway to quickly set it to behave as it did before (where it would automatically adjust to the parent container)?

nicktobolski avatar Oct 09 '17 19:10 nicktobolski

@nicktobolski you are probably limited to using !important

https://stackblitz.com/edit/material2-spinner-issue-vzdj9y?file=app/app.component.scss

willshowell avatar Oct 09 '17 20:10 willshowell

I've just run into this as well after upgrading to beta12. IMHO the old behaviour was much better, I prefer to size components via CSS rather than input values. Seems a bit hacky to have to use !important.

RobertDiPaolo avatar Oct 09 '17 22:10 RobertDiPaolo

@ghd8 's answer is the official way.

e-cloud avatar Oct 11 '17 06:10 e-cloud

Unfortunately setting the diameter doesn't solve the problem as the border won't change. For example, if you set the diameter to 16, the border thickness won't adapt and the spinner looks weird.

mawo87 avatar Oct 11 '17 10:10 mawo87

@mawo87 Can define the stroke width with [strokeWidth] input parameter https://material.angular.io/components/progress-spinner/api

karlos1337 avatar Oct 11 '17 10:10 karlos1337

@karlos1337 Thanks for help - I somehow overlookd this.

mawo87 avatar Oct 11 '17 10:10 mawo87

@ghd8 diameter seems to add some padding or w.e.: https://plnkr.co/edit/9LVEpXy8XJAAWjYtVOBh?p=preview

dgadelha avatar Oct 11 '17 19:10 dgadelha

@dgadelha

<mat-spinner [diameter]="48"></mat-spinner> instead of <mat-spinner diameter="48"></mat-spinner>

ghd8 avatar Oct 11 '17 19:10 ghd8

My bad, thank you!

dgadelha avatar Oct 11 '17 19:10 dgadelha

If you set a low diameter (e.g. 20) you may end up with an undesirable progress-spinner, such as the one below. This can be resolved by also configuring the strokeWidth to a low number (e.g. 2). spinner

ghost avatar Oct 30 '17 08:10 ghost

Closing as the height is controlled via diameter

josephperrott avatar Oct 31 '17 18:10 josephperrott

I'm still having this as an issues @josephperrott, I'm setting diameter and the px is still way to big. it ends up being a small circle for the spinner with a 100px width on mat-progress-spinner and svg even though the diameter is 20 and the circle is probably only 30px big

MikaAK avatar Nov 10 '17 06:11 MikaAK

@darkedges you need to bind to diameter with value binding, not string binding.

Coercion will be supported in https://github.com/angular/material2/pull/7791.

willshowell avatar Nov 10 '17 14:11 willshowell

@willshowell now I understand. Changed to

<mat-progress-spinner value="100" mode="determinate" [diameter]="68"></mat-progress-spinner>
<button mat-fab color="accent">
  <mat-icon class="icon">mic</mat-icon>
</button>

and the diameter value is being obeyed.

darkedges avatar Nov 10 '17 19:11 darkedges

While diameter and strokeWidth works, I cannot find a way to set them globally. This was possible when CSS was respected, it there a workaround apart from using !important?

EdmondChuiHW avatar Nov 30 '17 17:11 EdmondChuiHW