Using CSS variables
To inject prefixed CSS variables with the help comes get-var()
function, which takes four parameters: $name
$prefix
$suffix
and $unit
.
There is only $name
parameter required, and the $prefix
default value is equal to $var-prefix
, $suffix
default value is an empty string
, and $unit
default value is set to 0
.
The function returns var()
CSS function with the CSS variable of the $name
parameter with defaults or returns calc()
CSS function that multiplies by one unit CSS variable value of the same name.
For example, there is SCSS variable $layout-spacing
equal to 0.4rem
with equivalent prefixed CSS variable --s-layout-spacing
equal to 0.4
without rem
unit to have the ability to multiply it by the px
unit value and It's defined as follows.
To inject into any style the layout-spacing
CSS variable value there is a need to provide $unit
parameter to 1
.
Last updated