Several colors in this .scss file are defined as such:
$colors: (
primary : #cd0e11,
secondary: #23aa0b,
danger: #f53d3d,
light: #f4f4f4,
dark: #222
);
How do I access them? Say I want to set something to primary.
I tried:
h1 {
color: $colors:primary
}
This is Ionic 2, so it could be a framework specific thing.
Interpolation of variable names is currently not possible in SASS.
Sass variables and JavaScript. Sass is a pre-processing language, meaning it's turned into CSS before it ever is a part of a website. For that reason, accessing them from JavaScript in the same way as CSS custom properties — which are accessible in the DOM as computed styles — is not possible.
Sass variables are all compiled away by Sass. CSS variables are included in the CSS output. CSS variables can have different values for different elements, but Sass variables only have one value at a time.
Declaration of a variable in SASS: In SASS, you can define a variable by using $ symbol at the starting of the name of the variable and followed by its value.
I found out this is called SASS mapping. The following will work. It works like a key value fetcher.
color: map-get($colors, primary)
Check this out for more info on it.
You could try this:
h1 {
color: color($colors, primary);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With