I have some lists of SCSS variables which are used in mixins, can I create a ‘master’ list which the others inherit?
$vars: (
main-colour-active: #0b8579,
text: #424242,
button-text: $white,
font-family: $font-family-base,
);
$nav: (
inherit $vars,
background-color: $blue,
);
expected outcome
$nav: (
main-colour-active: #0b8579,
text: #424242,
button-text: $white,
font-family: $font-family-base,
background-color: $blue,
);
I have looked into scss inheritance, I know I could add those $vars to a variable within my $nav but would prefer them to all be in one list.
2
Answers
You can use
map.merge()
:Or:
Try it:
…compiles to:
you can use map-merge also you can get the index number of a map