Here is the code I am trying
@import "~variables";
:root
{
--color-primary: map-get($colors, blue);
}
button {
background: var(--color-primary);
}
in variables I have
$colors: (
black : #000000,
white : #FFFFFF,
blue: : #888888
}
Unfortunately it doesn't work, my buttons aren't blue. As scss is precompiled, I thought that would just work nicely.
you need to escape that scss function like so:
$colors: (
'black' : #000000,
'white' : #FFFFFF,
'blue' : #888888
);
:root {
--blue: #{map-get($colors, 'blue')}
}
body {
color: var(--blue);
}
Update: it's basically string interpolation that is needed.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加