Angular Material mat-spinner custom color

2020-03-08 12:04发布

Does anyone know how can I change mat-spinner color in Angular Material? Overriding css doesn't work. I tried changing color in material files but they can only be imported, I can't change anything there. I want it to be my custom color, not color from prebiult-themes.

11条回答
萌系小妹纸
2楼-- · 2020-03-08 12:32

Easy Fix!

Add custom css rules inside styles.css instead of component.css file

.mat-progress-spinner circle, .mat-spinner circle {
    stroke: #2A79FF!important;
}
查看更多
仙女界的扛把子
3楼-- · 2020-03-08 12:38

mat-spinner html code :

<mat-spinner color="accent" diameter="20" class="loading"></mat-spinner>

And now sass code :

.mat-spinner {
    ::ng-deep circle {
        stroke: #33dd82;
    }
}
查看更多
萌系小妹纸
4楼-- · 2020-03-08 12:38

This is best achieved by doing a custom theme.

https://material.angular.io/guide/theming

查看更多
Emotional °昔
5楼-- · 2020-03-08 12:43

Sample Color, strokeWidth, diameter and title

<mat-spinner strokeWidth="24" [diameter]="85" color="warn" title="Tooltip text here"></mat-spinner>
查看更多
欢心
6楼-- · 2020-03-08 12:50

use this code

<md-progress-circular md-diameter="20px"></md-progress-circular>

md-progress-circular path {
  stroke: purple;
}
查看更多
SAY GOODBYE
7楼-- · 2020-03-08 12:51

To your .css/.scss component file style add (it will works locally - in component only)

:host ::ng-deep .mat-progress-spinner circle, .mat-spinner circle {   
    stroke: #bada55;
}
查看更多
登录 后发表回答