OKLCH Color System Test
This page demonstrates the new OKLCH-based color system that generates harmonious color palettes from a single “signal” color.
How It Works
The system uses OKLCH color space (perceptually uniform) to:
- Extract DNA from your signal color (lightness, chroma, hue)
- Generate 6 semantic colors by rotating the hue
- Preserve vibrancy and visual weight across all colors
- Automatically adjust for dark mode
Signal Color
The current signal is: –signal: #d65d0e (Safety Orange)
Generated Pigments
All colors below are mathematically derived from the signal above:
--pigment-redErrors, Deletions
--pigment-yellowWarnings, Highlights
--pigment-greenSuccess, Insertions
--pigment-cyanInfo, Metadata
--pigment-blueLinks, Focus
--pigment-purpleMagic, AI
Semantic Colors
The system maps generated pigments to semantic names:
- Success: Success Message (uses green)
- Warning: Warning Message (uses yellow)
- Error: Error Message (uses red)
- Info: Info Message (uses blue)
- Link: This is a link (uses blue)
Test Different Signals
Try these in your browser DevTools console to see live color changes:
// Neon Pink Signal
document.documentElement.style.setProperty('–signal', '#ff00ff');
// Forest Green Signal
document.documentElement.style.setProperty('–signal', '#3a4a3a');
// Electric Blue Signal
document.documentElement.style.setProperty('–signal', '#0099ff');
// Clay Brown Signal (from issue description)
document.documentElement.style.setProperty('–signal', '#7a5a2e');
// Reset to default (Safety Orange)
document.documentElement.style.setProperty('–signal', '#d65d0e');
Dark Mode Test
Switch your OS theme to dark mode to see:
- All colors automatically brighten (+0.15 lightness)
- Hue and vibrancy preserved
- Maintains harmony and relationships
Technical Implementation
DNA Extraction
–dna-l: oklch(from var(--signal) l);
–dna-c: oklch(from var(--signal) c);
–dna-h: oklch(from var(--signal) h);
Safety Constraints
/* Minimum vibrancy for alerts (prevents gray from black/white) */
–safe-c: max(var(--dna-c), 0.12);
/* Readable text lightness */
–safe-l: clamp(0.35, var(--dna-l), 0.75);
Pigment Generation
/* Rotate hue while preserving lightness & chroma */
–pigment-red: oklch(var(--safe-l) var(--safe-c) 25);
–pigment-yellow: oklch(var(--safe-l) var(--safe-c) 85);
–pigment-green: oklch(var(--safe-l) var(--safe-c) 145);
/* etc… */
Dark Mode Adaptation
@media (prefers-color-scheme: dark) {
:root {
/* Brighten all pigments for visibility */
–pigment-red: oklch(calc(var(--safe-l) + 0.15) var(--safe-c) 25);
–pigment-yellow: oklch(calc(var(--safe-l) + 0.15) var(--safe-c) 85);
/* etc… */
}
}
Browser Support
- Chrome/Edge: 111+ (March 2023)
- Safari: 16.4+ (March 2023)
- Firefox: 113+ (May 2023)
Older browsers fall back to default colors (backward compatible).
Benefits
- One Color Generates All: Set
–signalonce, get complete palette - Consistent Vibrancy: All colors have matching visual weight
- Smart Dark Mode: Automatic brightness adjustment
- Temperature Preservation: Warm signals stay warm, cool signals stay cool
- Accessible: Built-in lightness constraints ensure WCAG AA compliance
- Customizable: Override any specific pigment if needed
Note: This system is mathematically precise and perceptually uniform thanks to OKLCH color space. Unlike HSL (which is broken – yellow looks brighter than blue at same lightness), OKLCH ensures 50% lightness looks the same for every hue.