Angular 2材质在按钮上使用较浅/较深的颜色 [英] Angular 2 Material use lighter/darker colors on button
本文介绍了Angular 2材质在按钮上使用较浅/较深的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种优雅的方法来使用带有角度2材质的按钮的原色或强调色的较浅/较暗的变体,而无需手动重新创建整个样式?
Is there any elegant way to use lighter/darker variants of either primary or accent colors with buttons in angular 2 material without recreating whole styling by hand?
推荐答案
如果使用sass,则可以将材质主题导入到scss文件中,并指定材质颜色,如下所示:
If you use sass you can import material theming into your scss file and target material colors like so:
app.component.scss
@import '~@angular/material/theming';
.buttonPrimary {
background-color: mat-color($mat-purple, 200);
}
.buttonAccent {
background-color: mat-color($mat-amber, A200);
}
app.component.html
<button md-raised-button class="buttonPrimary">primary</button>
<button md-raised-button class="buttonAccent">accent</button>
这篇关于Angular 2材质在按钮上使用较浅/较深的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文