Theme-Adaptive OKLab
Adjusts perceptual lightness and chroma automatically between light and dark themes.
- Stage 03: OKLab Color Science
- Built-In Preset
- 2 min read
- Updated 2026-11-15
Key Takeaways
- Recommended for dual-theme ('light' and 'dark') web applications.
- Automatically deepens perceptual lightness on light backgrounds for crisp WCAG contrast while keeping luminous hues in dark mode.
Visual Mechanism
Factory Signature
Re-exported from
@simplex-viz/core, @simplex-viz/svg, and @simplex-viz/reactStage 03 Overview →createThemeAdaptiveOklabColorStrategy<TItem, TTagMeta>(options?: ThemeAdaptiveColorOptions): SimplexColorStrategy<TItem, TTagMeta>Options & Defaults
darkLightnessDefault: 0.74
number
Perceptual OKLab lightness L used when theme === 'dark'.
lightLightnessDefault: 0.56
number
Perceptual OKLab lightness L used when theme === 'light'.
chromaDefault: 0.145
number
Target perceptual chroma shared across both themes.
Seamless Light & Dark Theme Parity
Colors optimized for dark backgrounds (L ≈ 0.74) wash out against white surfaces, while colors darkened for white surfaces look murky on #07090E. Theme-Adaptive OKLab inspects the active theme ('light' | 'dark') passed to <SimplexTopicGraph /> or SimplexSvgController, shifting OKLab lightness L while preserving hue angle h = atan2(b, a) so every cluster keeps its recognizable identity across theme switches.
Usage Example
import {
SimplexTopicGraph,
createThemeAdaptiveOklabColorStrategy,
} from '@simplex-viz/react';
const adaptiveColors = createThemeAdaptiveOklabColorStrategy();
<SimplexTopicGraph
items={items}
theme={isDark ? 'dark' : 'light'}
colorStrategy={adaptiveColors}
/>;