Back to Concepts
CSS UniverseTrack 4: Units & MathCSS Variables
Dynamic Tokens ยท Track 4 CapstoneCore Concept 16
CSS Custom Properties (Variables)
Live, reactive design tokens in pure CSS. Define variables on :root, scope them to components, update them with JavaScript, and toggle dark mode themes in 1 line of code.
1. Live CSS Variable Token Sandbox
Inspect Scoped Design Tokens
--brand-color:
--radius: 16px
var(--card-brand)
Reactive Component Token
Notice: The HTML element doesn't care if it's dark mode or light mode! It simply reads var(--card-bg) and var(--card-text).
2. Full Variables Workbench
Interactive Variables Visualizer
Interactive Lab
Custom Properties
Tweak design tokens as CSS variables. Values cascade automatically and update the live card.
Tokenized UI
:rootGap driven grid
--primary--accent--radius--gap
Variables cascade and can be overridden at any scope. Use them to theme components without refactoring markup.
color-mix()
Blend tokens for glass surfaces without maintaining extra swatches.
:root {
--primary: #7c3aed;
--accent: #22d3ee;
--radius: 16px;
--gap: 14px;
--elevation: 0 24px 60px rgba(0,0,0,0.35);
}
.card {
background: color-mix(in srgb, var(--primary) 35%, #0b1221);
border-radius: var(--radius);
gap: var(--gap);
box-shadow: var(--elevation);
}
Track 4 Complete! Next: Track 5
Begin Track 5: Colors17. Colors & Modern OKLCH
P3 wide gamut color spaces, perceptual lightness in OKLCH, and accessible contrast.