Sass variables should (optionally?) have `!default` flag
See original GitHub issueIn the scss/map-deep
format, the variables it generates (for use in the map) have the !default
flag:
// '!default' means if the variable is/was already defined, this declaration gets skipped
$my-var: #123ABC !default;
$tokens: (
my: (
var: $my-var,
)
);
…whereas the scss/variables
format doesn’t have that:
// No !default, so this variable can't be overridden during Sass compilation
$my-var: #123ABC;
Is there a reason why one has it and the other doesn’t? To me, it seems like:
- These should agree…It’s not necessarily a huge deal, but currently if we build both formats, downstream Sass compilations will either be able to override the values or not, based on which format they choose.
!default
should be added as an option so we can choose whether or not we want them to be able to override the variables from the configuration. (I guess that’s a feature request. 😄)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Creating Stylesheet Feature Flags With Sass !default
default is a Sass flag that indicates conditional assignment to a variable — it assigns a value only if the variable was previously ......
Read more >Variables - Sass
CSS variables can have different values for different elements, but Sass variables only have one ... To make this possible, Sass provides the...
Read more >A Sass `!default` use case - Thoughtbot
default flag to the end of the value. This means that if the variable has already been assigned to, it won't be re-assigned,...
Read more >SASS variables set inside of conditional? - Stack Overflow
You're misusing the !default flag. This flag means "set a value to a variable only if it has no value". – Andrey Mikhaylov...
Read more >The Ultimate Guide to Learning Sass/SCSS
Usually, when you assign a value to a variable and later assign another value to it, the original value is overwritten. To overcome...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We merged in #359 onto the 3.0 branch targeting the next major release. We will keep this issue open until the release. We want to see if this flag
themeable: true
on the token can be used in other built-in formats so that this is not SCSS specific. If anyone has ideas for this please open a PR or comment on this issue: #474 thanks!Closing this issue as this is now a feature in 3.0. You can get it today with
npm install style-dictionary@next