当然,您可以使用自己的 CSS 并自定义背景和前景色。不需要::ng-deep。 (/deep/ 和 ::ng-deep 目前都已弃用)
添加了几个 SCSS,这就是我的步进器的外观:我添加了自定义标签和图标所需的 SASS sn-ps:
已完成的步骤及其标签:
.mat-step-header .mat-step-icon-state-done, .mat-step-header .mat-step-icon-state-edit {
background-color: transparent !important;
color: $success;
+.mat-step-label{
color: $success !important;
}
}
进行中步骤及其标签:
.mat-step-header .mat-step-icon-selected{
// background-color: $primary;
background-color: transparent !important;
color: $primary;
+.mat-step-label{
color: $primary !important;
}
}
待办事项/默认步骤及其标签:
.mat-step-header .mat-step-label{
color: rgba(0, 0, 0, .54)
}
.mat-step-header .mat-step-icon {
color: rgba(0, 0, 0, .54);
background-color: transparent;
}
用于覆盖默认图标的 HTML:
我使用了很棒的字体图标来覆盖默认值:
<mat-horizontal-stepper>
<!-- Icon overrides. -->
<ng-template matStepperIcon="edit">
<i class="fa fa-check-circle"></i>
</ng-template>
<ng-template matStepperIcon="active">
<i class="fa fa-dot-circle-o"></i>
</ng-template>
<ng-template matStepperIcon="done">
<i class="fa fa-dot-circle-o"></i>
</ng-template>
<ng-template matStepperIcon="number">
<i class="fa fa-dot-circle-o"></i>
</ng-template>
</mat-horizontal-stepper>
注意:所有 SCSS 都应该在全局样式表中,而不是在组件特定的样式表中。如果样式存在于 Angular 组件的文件中,由于视图封装,它将不会被应用。 p>
如果需要,请在 SCSS 文件的开头定义颜色变量,如下所示:将 HEX 值替换为您的主题颜色。
$success: #35A255 !default;
$primary: #007CBB !default;