Roll Your Own CSS-in-JS Library (3) - Using CSS Variables
Saturday, March 13, 2021
In this post we will discard our changes in the previous post and switch to a new approach.
End result CSS variables CSS variables are also known as CSS Custom Properties. At a very high level:
We can set some value on a variable using --variable-name: value. The variable name has to start with --, and the definition has to happen within some selector or as inline styles. We can then read the value of a variable and supply it to some CSS property with the var() function, e.…