1

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.

2
  • what does your compiled code look like? Commented May 7, 2020 at 12:50
  • 1
    you need --color-primary: #{map-get($colors, blue)}; Commented May 7, 2020 at 12:51

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.