Angular 2 Material 在按钮上使用较浅/较深的颜色 [英] Angular 2 Material use lighter/darker colors on button

查看:25
本文介绍了Angular 2 Material 在按钮上使用较浅/较深的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何优雅的方法可以在 angular 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 Material 在按钮上使用较浅/较深的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆