How to override materializecss sass variables in vue?

a 夏天 提交于 2019-12-06 03:59:19

Before changing any default settings in materialized css; first, you need to import the component for which you want to change the settings for. After this you can override the default settings and then you should import materialize. For example if you want to change default color then create a file for example app.scss then write following code:

//please put the paths as per yours project directory structure
@import "materialize-css/sass/components/color";
$primary-color: color("blue", "lighten-2") !default;
@import 'materialize-css/sass/materialize'    

Note: app.css must be included in your page. As per my example app.css must be in your project root folder i.e. at same level as that of index.html

Now you can load app.scss or app.css in Vue 2 as require('../app.scss');

Visit official materialized github repo for viewing complete source.

In matrialize 1.0.0 however, follow these guildlines to override materialize colors:

  1. Define the value for the variable that you want to override (eg. $primary-color)
  2. Import the materialize.scss library

The definition of the override values must occur before importing the materialize.scss, that means that you can not use the matrial functions such as color()

Example:

// main.scss - the order of the imports is important !!!
@import './_colors';
@import 'materialize-css/sass/materialize.scss';

// _colors.scss
$primary-color: #03a9f4; //light-blue
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!