We know the advantages of using CSS4 variables but what if we need to get these values from a SASS function like so?:
:root {
--gap-l: toRem(10);
}
toRem
is a Sass function that I call to get the sizes dynamically:
$fontSize: 16;
@function toRem($val) {
@return $val / $fontSize * 1.6 + 0rem;
}
This won't fail but won't work either. To have this working we can just have the value directly on --gap-l
or keep using SASS vars.
If I try something like --gap-l: #{toRem(10)};
this is the error I get:
It doesn't call the SASS function