用自定义颜色设置角材料的主题

时间:2020-03-30 11:27:30

标签: angular angular-material

我想为我的angular 8应用程序更改整个主题

我在scss文件中包含以下内容:

@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/
$sp-app-primary: mat-palette($mat-grey,900);
$sp-app-accent:  mat-palette($mat-pink, A200, A100, A400);

// The warn palette is optional (defaults to red).
$sp-app-warn:    mat-palette($mat-red);

// Create the theme object (a Sass map containing all of the palettes).
$sp-app-theme: mat-light-theme($sp-app-primary, $sp-app-accent, $sp-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.
@include angular-material-theme($sp-app-theme);

所以现在我的垫子工具栏具有黑色背景,因此自定义主题正在起作用。

此外,我一生也无法更改默认字体颜色。我希望文本在黑色背景上为橙色,但是无论我做什么(我已经经历了很多堆栈溢出信息),文本始终都是白色...

设置材料时,我选择了靛蓝主题。这是我的问题吗?我应该选择自定义吗?

我什至无法用标准的css类覆盖mat-toolbar字体颜色,因为它们被默认样式覆盖了。

这让我发疯了。对我来说,角度文档似乎并不十分清楚。

1 个答案:

答案 0 :(得分:0)

您尝试过-> example吗?

它帮助我应用了自己的自定义主题,您可以轻松地根据需要对其进行自定义。