Roll Your Own CSS-in-JS Library (5) - Tagged Templates
Wednesday, March 24, 2021
In this post, we will explore a different CSS-in-JS syntax.
CSS-in-JS but using CSS syntax End result:
Notice that we get to write CSS similar to template strings rather than as objects.
This has a few advantages:
Our CSS code now looks closer to vanilla CSS. We can sequence CSS properties. We can duplicate CSS properties to support fallback behavior. In practice, 1 is probably the strongest driver for adopting this syntax, as typically there’s no benefit in sequencing CSS properties except for fallback behavior.…