I have a number of CSS variables containing color values. I'd like to define these in HSL format, but can I let Sass convert these to hex values?
Input:
:root {
--dark: hsl(210, 50%, 13%);
}
Output:
:root {
--dark: #112132;
}
According to the SASS documentation SASS has a build-in module to handle colors in hsl format:
https://sass-lang.com/documentation/modules/
From documentation:
Global Functions
hsl($hue $saturation $lightness)
hsl($hue $saturation $lightness / $alpha)
hsl($hue, $saturation, $lightness, $alpha: 1)
hsla($hue $saturation $lightness)
hsla($hue $saturation $lightness / $alpha)
hsla($hue, $saturation, $lightness, $alpha: 1) //=> color
SASS variables compile at runtime, CSS custom properties compile when they're used. - https://dev.to/nicm42/combining-sass-variables-with-css-custom-properties-5hj7 - seems that it does not work that way.