按 angular material 主题设置文本输入颜色
setting text input color by angular material theme
我对 angular material 主题化真的很陌生。实际上是大约 30 分钟前开始的! :)
所以我可以设置主色、重音色和警告色。
现在我正在尝试在我的主题中设置文本输入颜色。
不知道如何正确地做到这一点...
我检查了 mat-input
元素并注意到 placeholder
标签的颜色由以下 类 设置:
mat-form-field-appearance-legacy
和 mat-form-field-label
.
我创建了以下主题文件:
@import '~@angular/material/theming';
// 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/
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).
$candy-app-warn: mat-palette($mat-amber);
// Create the theme object (a Sass map containing all of the palettes).
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
// 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.
.mat-form-field-appearance-legacy .mat-form-field-label {
color: white;
}
@include angular-material-theme($candy-app-theme);
这根本不会影响 mat-input
占位符颜色。
所以我想了解如何使用主题正确设置输入颜色。
如有任何关于此问题的想法,我们将不胜感激。
考虑在开始之前查看 Customizing Component Styles 指南。
无论如何,您必须使用 !important
样式,因为您的样式将被 Angular Material 的样式覆盖:
// ...
.mat-form-field-appearance-legacy .mat-form-field-label {
color: white !important;
}
我对 angular material 主题化真的很陌生。实际上是大约 30 分钟前开始的! :)
所以我可以设置主色、重音色和警告色。
现在我正在尝试在我的主题中设置文本输入颜色。
不知道如何正确地做到这一点...
我检查了 mat-input
元素并注意到 placeholder
标签的颜色由以下 类 设置:
mat-form-field-appearance-legacy
和 mat-form-field-label
.
我创建了以下主题文件:
@import '~@angular/material/theming';
// 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/
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).
$candy-app-warn: mat-palette($mat-amber);
// Create the theme object (a Sass map containing all of the palettes).
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
// 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.
.mat-form-field-appearance-legacy .mat-form-field-label {
color: white;
}
@include angular-material-theme($candy-app-theme);
这根本不会影响 mat-input
占位符颜色。
所以我想了解如何使用主题正确设置输入颜色。
如有任何关于此问题的想法,我们将不胜感激。
考虑在开始之前查看 Customizing Component Styles 指南。
无论如何,您必须使用 !important
样式,因为您的样式将被 Angular Material 的样式覆盖:
// ...
.mat-form-field-appearance-legacy .mat-form-field-label {
color: white !important;
}