在Angular 6(和7)中进行Mat-button-toggle的主题设置 [英] Theming in Angular 6 (and 7) for Mat-button-toggle
本文介绍了在Angular 6(和7)中进行Mat-button-toggle的主题设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了很棒的链接如何自定义材质切换按钮。我成功设置了 background-color
和 font-weight
的方式
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);
但是字体本身仍然保持黑色-使用<$ c $时这不是默认颜色c> color = primary 。
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?
推荐答案
感谢@Akhi Akl我,并仔细研究了主题,发现以下针对 mat-button-toggle
彩色 primary
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);
这篇关于在Angular 6(和7)中进行Mat-button-toggle的主题设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文