我使用角度5材料,我创建了一个theme.scss如下 theme.scss
@import '~@angular/material/theming';
@include mat-core();
$custom-primary: mat-palette($mat-deep-purple,600);
$custom-accent: mat-palette($mat-lime, 100);
$custom-warn: mat-palette($mat-red);
$custom-theme: mat-light-theme($custom-primary, $custom-accent, $custom-warn);
@include angular-material-theme($custom-theme);
// ALTERNATIVE THEME
$alt-primary: mat-palette($mat-yellow);
$alt-accent: mat-palette($mat-grey, 200);
$alt-theme: mat-dark-theme($alt-primary, $alt-accent);
.alternative {
@include angular-material-theme($alt-theme);
}
我有我的默认styles.scss如下 style.scss
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
.fa-icon-nav {
color: #507889;
font-size: x-large;
}
颜色当前在fa-icon-nav中进行了硬编码 . 我希望它使用当前所选主题的原色 . 如果可能,请告知如何使用它?很高兴听到这是完全错误的做法以及如何做到这一点 .
1 回答
EDIT:
ADDED ONLINE DEMO
我正在开发一个项目,我使用了Material 2主题,我使用了这种方法,我使用类名并全局添加颜色类 .
这就是我做的:
FileName:mytheme-sidemenu.scss:
这是我的主题文件:mytheme-theme.scss:
并在app.module.ts更新此:
这已经问了,我只是复制粘贴我的回答here
EDIT :
根据您的需要,您可以实现这一目标:
I have my default styles.scss as below style.scss 您需要更改为_theme-color.scss
或者您可以使用here中的此材质颜色库