Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

angular - SCSS dynamic theme with css variable

I am trying to apply the theme dynamically using the CSS variable.

    $primary: #3da677;

    // Bootstrap
    $theme-colors: ("primary": $primary,
    );

Above is working fine but what I want is:

$theme-colors: ("primary": var(--primary),
        );

Above is throwing an error that says "$color: var(--primary) is not a color"

I am assigning value in the variable using below code:

document.documentElement.style.setProperty(--primary, "#ec782e");

Below is the root scss file:

:root {
  @each $name, $color in $theme {
    --#{$name}: #{$color};
  }
}

Please help!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...