Bootstrap: Correct import order of _custom.scss and _variables.scss?

Created on 23 Dec 2016  路  4Comments  路  Source: twbs/bootstrap

Docs explain:

Copy and paste relevant lines from _variables.scss into the custom file

Currently bootstrap.scss imports _custom.scss before _variables.scss which seems to make any variable declaration within _variables.scss unavailable for use within _custom.scss.

@import "custom"; // (contains customization for: $lead-font-size)
@import "variables";

Error: Undefined variable: "$lead-font-size".

Whereas when I swap the order of these two files it compiles without errors.

@import "variables";
@import "custom"; // (contains customization for: $lead-font-size)
css has-pr v4

All 4 comments

So the problem here is using _custom for _changing_ variables vs being able to do that and use the other variables. I think we can safely change this...

@mdo I think this introduced a new issue, which is that now you can't overwrite variables like $border-radius anymore. If you do that, it has zero effect. The reason is that other values are inferred in the _variables.scss file that have already used the default supplied value.

I understand the intent of this change, but I think it should be reverted back in order to provide greatest flexibility. What @constructit originally wanted to achieve is still possible, it just requires a little extra work because all the referenced variables need to be copied over and declared in the _custom.scss as well.

@daniellangnet The order has been corrected in v4-dev with _custom.scss coming first once again. Variable overrides need to just remove the !default. The downside is this order doesn't allow for using other variables in this file; it's purely for overrides.

This is problematic as utility variables like $gray-light are inaccessible from custom styles. Or am I misunderstanding?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fohlsom picture fohlsom  路  3Comments

cvrebert picture cvrebert  路  3Comments

bellwood picture bellwood  路  3Comments

leomao10 picture leomao10  路  3Comments

IamManchanda picture IamManchanda  路  3Comments