CSS custom property
A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).
In more detail
Custom properties are resolved by the browser while the page runs, so changing one instantly updates everything that uses it. They follow the cascade and are inherited, so redefining one on an element changes it only for that element's subtree. This makes them the natural way to deliver design tokens and themes on the web.
Example
:root { --spacing-md: 1rem; } .card { padding: var(--spacing-md); }Related terms
- var() — The CSS function that reads a custom property, with an optional fallback: var(--brand, #2563eb).
- :root — The CSS selector that matches the document's top element, the html element, where global custom properties are usually declared.
- theming — Giving the same components different looks, such as light, dark or a different brand, by swapping the token values they use.
- CSS cascade — The CSS process that decides which of several competing rules sets a property on an element.
Taught in
- Token Transformation: Style Dictionary & Multi-Platform Outputs — Design Systems & Component Engineering
- CSS Custom Properties & Dynamic Theming Architecture — Design Systems & Component Engineering
- Tailwind CSS v4 Engine: CSS Variables & Theme Extensions — Design Systems & Component Engineering