问题
How can I change the color of the using CSS?
Saw on another post that if I use the following code, it would change it, but I had no luck with it so far.
.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element {
background-color:rgb(255, 37, 37);
}
.mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle {
border-color: rgb(66, 134, 244);
}
.mat-radio-button.mat-accent .mat-radio-inner-circle {
background-color: rgb(66, 134, 244);
}
Also, how could I use the rest of the color hues?
<mat-radio-button color="accent">Hello, World</mat-radio-button>
Let's say that I want to use from the Accent color, the hue of 300 or A100, how would I go about to doing that?
I've tried using accent-100
and accent hue-100
but, it doesn't work
回答1:
add this css in your style.css/style.scss
Stackblitz
style.css/style.scss
.mat-radio-button.mat-accent.mat-radio-checked .mat-radio-outer-circle{
border-color:rgb(66, 134, 244);
}
.mat-radio-button.mat-accent .mat-radio-inner-circle{
color:rgb(66, 134, 244);
background-color:rgb(66, 134, 244) ;
}
.mat-radio-button.mat-accent .mat-radio-ripple .mat-ripple-element {
background-color:rgb(255, 37, 37,.26);
}
回答2:
You can set custom color using following approach:
Put this code in your module declaration:
providers: [{
provide: MAT_RADIO_DEFAULT_OPTIONS,
useValue: { color: 'accent' },
}]
来源:https://stackoverflow.com/questions/52552284/angular-6-material-hues-and-how-to-change-the-color-of-mat-radio-button