CSS custom property
A property you define yourself with a double-hyphen name, such as --brand: #0066cc, and read elsewhere with var(--brand).
In more detail
Unlike preprocessor variables, custom properties live in the browser at runtime: they cascade and inherit like other properties, so a value set on :root can be overridden for one card or a dark theme. Changing one in JavaScript restyles every element that uses it.
Related terms
- var() — The CSS function that reads a custom property, with an optional fallback: var(--brand, #2563eb).
- @property — A CSS rule that registers a custom property with a type, an initial value and whether it inherits.
- theming — Giving the same components different looks, such as light, dark or a different brand, by swapping the token values they use.
- design token — A named design decision, such as a colour, font size or spacing value, stored as data so every platform can use the same value.
- CSS inheritance — The CSS rule that some properties, mostly text-related ones like color and font, pass their value from a parent to its descendants unless overridden.
Taught in
- CSS Custom Properties: Scoping, Fallbacks And Theming — Frontend Architecture & Web Platform