简体   繁体   English

如何在Material Design Lite中使用自定义颜色?

[英]How to use Custom colors with Material Design Lite?

I am new to Material Design Lite. 我是Material Design Lite的新手。 I want to use a custom color scheme, particularly the primary color and accent color. 我想使用自定义配色方案,特别是原色强调色。

I have seen their theme builder tool , but it only offers a few colors. 我见过他们的主题构建工具 ,但它只提供了一些颜色。

How can I do that? 我怎样才能做到这一点? How can I use custom (primary and accent) colors (which are not included in their theme builder tool) in my site, which uses Material Design Lite? 如何在我的网站中使用自定义(主要和重点)颜色(未包含在其主题构建工具中),使用Material Design Lite?

i reckon there is no out-of-the-box way to achieve this. 我认为没有开箱即用的方法来实现这一目标。

I guess we may have to tinker around _color_definitions.scss which has pre-defined colors as selected in the theme-picker ,like 我想我们可能不得不修改_color_definitions.scss ,它具有在主题选择器中选择的预定义颜色,如

$palette-red:
"255,235,238"
"255,205,210"
"239,154,154"
"229,115,115"
"239,83,80"
"244,67,54"
"229,57,53"
"211,47,47"
"198,40,40"
"183,28,28"
"255,138,128"
"255,82,82"
"255,23,68"
"213,0,0";

or build your own sass rules to generate required custom theme. 或者构建自己的sass规则以生成所需的自定义主题。

by now there is a way to do this, check out this question (including the fixes in the answer). 到目前为止有一种方法可以做到这一点,看看这个问题 (包括答案​​中的修复)。

In short: (the following lines were taken and fixed from that question, but I didn't test them myself) 简而言之:(以下几行是从这个问题中解决的,但我没有自己测试)

scss: SCSS:

@import 'colors';
@import '../../../node_modules/material-design-lite/src/material-design-lite'; `

_colors.scss: _colors.scss:

$color-primary: "255, 0, 0";
$color-accent: "0, 0, 255";

Github reference Github参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM