1

I have a hundreds of SASS variables in the following format:

$color-apples-bg: red;
$color-apples-fg; white;
$color-bananas-bg: yellow;
$color-bananas-fg: black;
$color-cherries-bg: burgundy;
$color-cherries-fg: white;

I'm trying to concatenate and interpolate the correct variable name like so:

$fruits: apples, bananas, cherries;

@each $name in $fruits {
  body.#{$name} {
    background-color: $color-#{$name}-bg;
    color: $color-#{$name}-fg;
  }
}

However, this results in an error on compile. Is it possible to do this some way?

user1444027
  • 4,983
  • 7
  • 29
  • 39

0 Answers0