CSS Custom Properties
A guide to building dynamic, themeable stylesheets using CSS custom properties and design token patterns.
Usage
Ask about CSS variables, theming, design tokens, or dynamic styling patterns.
Examples
- "Create a theme system with light and dark modes"
- "How do I update CSS variables with JavaScript?"
- "Build a design token system with custom properties"
Guidelines
- Define global tokens on :root and component tokens on the element
- Use meaningful naming conventions like --color-primary
- Provide fallback values with var(--prop, fallback)
- Leverage cascade and inheritance for theme scoping
- Use custom properties for values that change, not static values