更改材质设计中的复选框勾选颜色

问题描述 投票:0回答:1
angular sass angular-material
1个回答
1
投票

请通读

angular-material theming documentation
这包含为您的角度材质组件主题化的完美说明,目前,下面是我使用
green-palette
将所有组件设置为绿色主题时的工作示例。这将帮助您达成最终解决方案!

主题

...
$theme-primary: mat.define-palette(mat.$green-palette);
$theme-accent: mat.define-palette(mat.$green-palette);
...

完整主题scss

// Custom Theming for Angular Material
// For more information: https://material.angular.io/guide/theming
@use '@angular/material' as mat;
// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat.core();

// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$theme-primary: mat.define-palette(mat.$green-palette);
$theme-accent: mat.define-palette(mat.$green-palette);
// you can also do below
// $theme-accent: mat.define-palette(mat.$green-palette, A200, A100, A400);

// The warn palette is optional (defaults to red).
$theme-warn: mat.define-palette(mat.$red-palette);

// Create the theme object. A theme consists of configurations for individual
// theming systems such as "color" or "typography".
$theme: mat.define-light-theme(
  (
    color: (
      primary: $theme-primary,
      accent: $theme-accent,
      warn: $theme-warn,
    ),
    typography: mat.define-typography-config(),
  )
);

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include mat.all-component-themes($theme);

html

<div class="label-input-block top-centre-form">
  <mat-form-field class="green-input" name="gadsCustomerId" id="gadsCustomerId">
    <mat-label>Select accounts</mat-label>
    <mat-select multiple>
      <mat-option *ngFor="let cid of customer_list" [value]="cid.id">
        {{ cid.account_name }} [{{ cid.id }}]
      </mat-option>
    </mat-select>
  </mat-form-field>
</div>
<div class="label-input-block top-centre-form">
  <mat-form-field class="green-input">
    <mat-label class="green-input">From Days Ago</mat-label>
    <input
      type="number"
      class="green-input"
      name="fromDaysAgo"
      id="fromDaysAgo"
      matInput
    />
  </mat-form-field>
</div>
<mat-label class="green-input">checkbox</mat-label>
<mat-checkbox class="example-margin">Check me!</mat-checkbox>

堆栈闪电战

© www.soinside.com 2019 - 2024. All rights reserved.