Docs Navigation (Stage 03)›

Theme-Adaptive OKLab

Adjusts perceptual lightness and chroma automatically between light and dark themes.

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

Light Surface · Target L ≈ 0.56Crisp WCAG contrast on whiteDark Surface · Target L ≈ 0.74Same hue angles · lifted luminance
Adapts perceptual lightness L and chroma C automatically to canvas polarity (L ≈ 0.56 on crisp light backgrounds vs. L ≈ 0.74 on dark obsidian surfaces) while preserving hue identity.

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}
/>;