Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating css variables with scss @each not working

Tags:

css

sass

ionic4

I am working with ionic 4 project and scss. I am having some strange behaviour, while I am trying to create a global CSS variables using @each:

:host {
      $colors-availability: (
        early-day: #e8ab00,
        long-day: #854fa5,
        whole-day: #fe307b,
        all-day: #32773e,
        morning: #87cc93,
        afternoon: #4bb15d,
        late: #fa8072,
        twilight: #40e0d0,
        night: #16151b
      );

      @each $name, $color in $colors-availability {
        --ion-color-#{$name}: $color;
      }
}

This is my code in theme/variables.scss file. I am expecting to have all these variable with respecting colours, but the output is this:

enter image description here

I don't have the hash colour values. Any idea? I tried everything(color() function, etc..). Thanks.

like image 569
Keryanie Avatar asked Dec 27 '25 16:12

Keryanie


1 Answers

Try something like this as below:

--ion-color-#{$name}: #{$color};
like image 163
Sonia Avatar answered Dec 30 '25 09:12

Sonia