在Angular 上,我try 将复选框标记和输入值下划线更改为绿色,而不是默认的紫色.

我怎么才能解决这个问题呢?

    <div class="label-input-block top-centre-form">
      <mat-form-field class="green-input"
        name="gadsCustomerId"
        formControlName="gadsCustomerId"
        id="gadsCustomerId">
        <mat-label>Select accounts</mat-label>
        <mat-select [formControl]="selectedCidList" 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>
    <ng-template matStepLabel>Configure date range</ng-template>
    <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"
          formControlName="fromDaysAgo"
          id="fromDaysAgo"
          matInput
        />
      </mat-form-field>
    </div>

https://imgur.com/a/1deeM0L

https://imgur.com/a/fFJJOxM

推荐答案

请通读angular-material theming documentation这包含了你的Angular material 组件主题的完美说明,目前,下面是一个工作的例子,当我使用green-palette来设计一个绿色主题的所有组件的样式.这将帮助您达成您的最终解决方案!

主旋律

...
$主旋律-primary: mat.define-palette(mat.$green-palette);
$主旋律-accent: mat.define-palette(mat.$green-palette);
...

full 主旋律 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 主旋律 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/
$主旋律-primary: mat.define-palette(mat.$green-palette);
$主旋律-accent: mat.define-palette(mat.$green-palette);
// you can also do below
// $主旋律-accent: mat.define-palette(mat.$green-palette, A200, A100, A400);

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

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

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

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>

stackblitz

Angular相关问答推荐

在Angular 17中加载页面时打开打印对话框

更改物料设计中的复选框勾选 colored颜色

Primeng:安装ANGLE 16.2.0版本

如何将 Angular 中的导航路由到同一页面并重新加载

Angular 12 区域环境切换器

IonicStorageModule似乎不是 NgModule 类

从具有特定 node 值的现有数组创建新数组

如何处理Angular 延迟订阅

如何从 RxJS 重试中排除某些 url

Angular 从 13.3.8 恢复到 13.3.7

如何为所有模块全局声明指令?

如何修复 [Object: null prototype] { title: 'product' }

Angular2 SVG xlink:href

取消订阅服务中的http observable

Angular 7 测试:NullInjectorError:No provider for ActivatedRoute

如何在Angular 4中为数字管道指定语言环境千位分隔符

Angular 2 setinterval() 继续在其他组件上运行

Angular 6在输入键上添加输入

Angular 2:formGroup 需要一个 FormGroup 实例

Angular 2 http 没有得到