用于 Mat-button-toggle 的 Angular 6(和 7)主题

LeO*_*LeO 1 angular-material angular angular-material-6

我找到了如何自定义材质切换按钮的精彩链接。我成功设置background-colorfont-weight我想的方式

@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);
Run Code Online (Sandbox Code Playgroud)

但不知何故,字体本身保持黑色 - 这不是使用color="primary".

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

LeO*_*LeO 5

感谢@Akhi Akl I 并调查主题,我找到了以下mat-button-toggle彩色解决方案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);
Run Code Online (Sandbox Code Playgroud)