style.setProperty()
DOM methods for writing and reading a single CSS property, including custom properties, on an element's inline style.
In more detail
element.style.setProperty("--sys-bg", "#111") changes a custom property at runtime, and getPropertyValue reads it back. The lesson uses them to swap themes on an element without rebuilding any stylesheet.
Related terms
- CSS custom property — A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).
- theming — Giving the same components different looks, such as light, dark or a different brand, by swapping the token values they use.
Taught in
- CSS Custom Properties & Dynamic Theming Architecture — Design Systems & Component Engineering