问题
I found the wonderful link how to customize the Material toggle button. I succeed to set the background-color
and the font-weight
the way I want with
@import '~@angular/material/theming';
@include mat-core();
$app-primary: mat-palette($mat-indigo);
$app-accent: mat-palette($mat-pink, A200, A100, A400);
$app-theme: mat-light-theme($app-primary, $app-accent);
@mixin mix-app-theme($app-theme) {
$primary: map-get($app-theme, primary);
$accent: map-get($app-theme, accent);
.mat-button-toggle-checked {
background-color: mat-color($primary);
font-weight: bold;
color:mat-color($primary); // <=== does not work!!!
}
}
// Include the mixin
@include mix-app-theme($app-theme);
But somehow the font itself remains on black - which is not the default color when using color="primary"
.
Any idea how to include the fore-color
as well - properly?
回答1:
try using this
.mat-button-toggle-label-content{
color:mat-color($primary)
}
if you want change color of checked button only try this
.mat-button-toggle-checked {
.mat-button-toggle-label-content{
color:mat-color($primary)
}
}
回答2:
Thanx to @Akhi Akl I and looking into the themes I found the following solution for mat-button-toggle
in color primary
@import '~@angular/material/theming';
@include mat-core();
$app-primary: mat-palette($mat-indigo);
$app-accent: mat-palette($mat-pink, A200, A100, A400);
$app-theme: mat-light-theme($app-primary, $app-accent);
@mixin mix-app-theme($app-theme) {
$primary: map-get($app-theme, primary);
.mat-button-toggle-checked {
background-color: mat-color($primary);
font-weight: bold;
.mat-button-toggle-label-content{
color: $light-primary-text;
}
}
}
// Include the mixin
@include mix-app-theme($app-theme);
来源:https://stackoverflow.com/questions/53836382/theming-in-angular-6-and-7-for-mat-button-toggle