用于 Mat-button-toggle 的 Angular 6(和 7)主题 [英] Theming in Angular 6 (and 7) for Mat-button-toggle

查看:21
本文介绍了用于 Mat-button-toggle 的 Angular 6(和 7)主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了很棒的链接如何自定义材质切换按钮.我成功地以我想要的方式设置了 background-colorfont-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);

但不知何故字体本身保持黑色 - 这不是使用 color="primary" 时的默认颜色.

But somehow the font itself remains on black - which is not the default color when using color="primary".

知道如何正确地包含 fore-color 吗?

Any idea how to include the fore-color as well - properly?

推荐答案

感谢@Akhi Akl I 并查看主题我找到了以下解决方案 mat-button-toggle in color 主要

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);

这篇关于用于 Mat-button-toggle 的 Angular 6(和 7)主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆