Skip to main content
Theodore's headshot Theodore's avatar
Theodore S. Lindsey

Parametric oklch Theme Demo

The premise of this theme approach is to drive an entire color theme from a few key parameters. The mechanism by which this operates is the CSS OkLCH color's ability to derive from another color.

Guiding principles:

A few observations:

Primary Hue
Primary Chroma
Primary Lightness

For this to work, I'm using the following CSS variables :root { --color-primary: oklch(0.9 0.20 290 / 1); --color-accent: oklch(from var(--color-primary) calc(1.0 - l) 0.3 calc(240 + h) / 0.8); --color-contrast: var(--color-accent); --color-contrast-inverse: var(--color-primary); --color-background: oklch(from var(--color-primary) l c h / 0.8); --color-background-header: var(--color-background); --color-background-main: var(--color-background); --color-background-nav: var(--color-background); --color-background-footer: var(--color-background); --color-text: var(--color-accent); --color-text-link: oklch(from var(--color-text) l c calc(120 + h) / 1); --color-text-link-hover: oklch(from var(--color-text-link) calc(0.8 * l) c h / 1); }