Anders är en webbutvecklare och hårdrockare som gillar brädspel, kaffe och öl.

Utmärkta exempel på att använda CSS custom properties

In practice, component definitions have way more styles than just colours. There’s a bunch of box-model properties, maybe a display, and possibly text styling instructions. In any case, a lot of lines of CSS.

If you use custom properties only for those CSS properties that will change you give future CSS developers a much better and quicker insight in how your component works. If the definition uses a custom property that means the property may change in some circumstances. If it uses a fixed definition you know it’s a constant.

CSS custom properties är något som jag själv försöker tillämpa så mycket jag kan i projekt. Denna artikel öppnade några dörrar till och gör det än tydligare att det är skillnad på Sass-variabler och CSS Custom Properties: man ska kombinera dem, inte välja en av dem.

På Twitter-tråden om artikeln kompletterade Sara Soeidan med en egen artikel om att arbeta med CSS custom properties, som också är läsvärd.

Källa: Two options for using custom properties