【问题标题】:Theming Angular Material with custom colours使用自定义颜色主题化 Angular 材质
【发布时间】:2020-07-10 18:17:57
【问题描述】:

我想为我的 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);

所以现在我的 mat-toolbar 有黑色背景,所以自定义主题可以正常工作。

我也不能终生更改默认字体颜色。我希望文本在黑色背景上显示为橙色,但无论我做什么(我经历过大量堆栈溢出帖子),文本始终是白色的......

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

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

这让我发疯。角度文档对我来说似乎并不完全清楚。

【问题讨论】:

  • 是的,但这似乎是针对自定义组件而不是针对整个默认配色方案。此外,我如何更改字体颜色也不是很清楚......(我对 Scss 还不是很热)。

标签: angular angular-material


【解决方案1】:

您尝试了吗 -> https://materialtheme.arcsine.dev

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

【讨论】:

    猜你喜欢
    • 2019-05-12
    • 1970-01-01
    • 2019-06-11
    • 2018-05-09
    • 2018-01-02
    • 2019-07-06
    • 2018-07-29
    • 1970-01-01
    • 2020-08-06
    相关资源
    最近更新 更多