我想您将不得不求助于获取主题定义的scss 版本并根据自己的喜好提取调整后的值。
scss 来源似乎没有与材料分发捆绑在一起,因此请转到 https://github.com/angular/components/blob/master/src/material/core/theming/prebuilt/purple-green.scss 以查看其来源。
那么:
my-custom-theme-definition.scss
@import '~@angular/material/theming';
// taken from https://github.com/angular/components/blob/master/src/material/core/theming/prebuilt/purple-green.scss
// Define a theme.
$my-custom-primary: mat-palette($mat-purple, 700, 500, 800);
$my-custom-accent: mat-palette($mat-green, A200, A100, A400);
$my-custom-theme: mat-dark-theme((
color: (
primary: $my-custom-primary,
accent: $my-custom-accent
)
));
my-custom-theme.scss(在您的全局 styles.scss 中导入一次)
@import 'my-custom-theme-definition';
// IMPORT ONLY ONCE, AS ALL STYLES ARE BEING OUTPUT
// Include non-theme styles for core.
@include mat-core();
// Include all theme styles for the components.
@include angular-material-theme($my-custom-theme);
other-component.scss
@import 'my-custom-theme-definiton';
.chat-header {
color: mat-color(map-get($my-custom-theme, primary), 'lighter'); // or 'darker' or some value defined in https://github.com/angular/components/blob/master/src/material/core/theming/_palette.scss#L105
}