:root
The CSS selector that matches the document's top element, the html element, where global custom properties are usually declared.
In more detail
Declaring tokens on :root makes them available to every element on the page through inheritance. Themes then override some of them on a lower element, such as one carrying data-theme="dark".
Related terms
- CSS custom property — A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).
- data attribute — A custom HTML attribute whose name starts with data-, such as data-theme="dark", used to store extra information 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