我正在研究一个黑色背景的 Angular Material 日期选择器。如何将日期选择器图标、下划线和占位符文本的默认颜色更改为全白色?
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
最佳答案
您可以使用::ng-deep。这是工作示例 https://stackblitz.com/edit/angular-mat-datepicker-qj73og
::ng-deep .mat-focused .mat-form-field-label {
/*change color of label*/
color: white !important;
}
::ng-deep.mat-form-field-underline {
/*change color of underline*/
background-color: white !important;
}
::ng-deep.mat-form-field-ripple {
/*change color of underline when focused*/
background-color: white !important;;
}
::ng-deep .mat-form-field-label {
/*change color of label*/
color: white !important;
}
mat-datepicker-toggle {
color: white !important;
}
关于css - 更改 Angular 日期选择器 Material 组件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57035750/