angular - 如何有效地使用 Angular Material 自定义调色板颜色 Angular Material
问题描述
我正在使用自定义材料调色板。使用其默认阴影、深色阴影、浅色阴影定义了主要和重音调色板,如下所示:
$my-app-primary: mat-palette($md-lightprimary ,500,900,A700 );
$my-app-accent: mat-palette($md-lightaccent, 500,900,A100);
$my-app-warn: mat-palette($md-warn);
/*finalize by creating a $my-app-theme variable that combines our color definitions with the mat-light-theme function,*/
$my-app-theme: mat-light-theme($my-app-primary, $my-app-accent, $my-app-warn);
/* and finally include the result of calling the angular-material-theme function with our $my-app-theme.*/
@include angular-material-theme($my-app-theme);
问题:
1. 如果我在代码中使用color="primary"
或color="accent"
设置default
颜色阴影,问题是,如何使用我们在主题初始设置中使用的lighter
和- 阴影。darker
2.如何使用调色板中的任何其他色调作为primary
或accent
色调。
解决方案
检查我在下面编写的代码。检查注释行的用法
主题.scss
$my-app-primary: mat-palette($md-lightprimary ,500,900,A700 );
$my-app-accent: mat-palette($md-lightaccent, 500,900,A100);
$my-app-warn: mat-palette($md-warn);
$my-app-theme: mat-light-theme($my-app-primary, $my-app-accent, $my-app-warn); //gives light theme
$my-app-dark-theme: mat-dark-theme($my-app-primary, $my-app-accent, $my-app-warn); //gives dark version of the above theme
//apply this class to any element you want to apply dark theme or set class to <body> so apply it to whole site
.dark-theme {
@include angular-material-theme($my-app-dark-theme);
}
@include angular-material-theme($my-app-theme); //default theme
推荐阅读
- flutter - 打开应用程序时如何避免打开状态栏和底部按钮栏?
- node.js - 当我在 nuxt 中选择 express 作为集成服务器端框架时,导入、导出和其他 es6 功能不起作用?
- javascript - 单击按钮,将数据添加到 SQL 并再次单击以删除数据,需要 php 代码
- excel - 循环遍历所有数据透视表的所有数据透视字段值
- java - 如何区分从 cardview 子项的 onclicklistener 传递到 OnActivityResult 的意图
- reactjs - TypeError:无法读取未定义反应的属性“道具”
- c# - 异同点:ViewModelLocator、ServiceLocator、依赖注入
- python - 正在为变量返回“无”梯度
- linux - 比较两个列并使用 awk 打印一个新文件
- angular - “ModalContainerComponent”类型上不存在属性“显示”