Play with CSS variables: 10 levels of custom properties, scoping, calc and theming. A CSS variables game for mastering dynamic design systems.
CSS Custom Properties (CSS variables) start with --. They're defined in a selector (usually :root) and used with var(--name). They work like variables in a programming language.
CSS variables can be overridden in a more specific selector. The override value applies to that element and all its descendants. That makes per-component theming easy.
var(--name, fallback) takes a second parameter as the fallback. If the variable isn't defined, the fallback is used. Useful for default values.
calc() does calculation in CSS. Combined with a variable: calc(var(--x) * 2). Useful for spacing systems and responsive typography.
currentColor is a keyword that refers to the current color value. Useful for making a border, shadow, or SVG that automatically follows the text color.