opyeb ColorOKLCH

15 guides · Tokens

Dark mode tokens — a rearrangement, not an inversion

Basis 28 November 2026 · Tokens · about 7 min

A dark theme made by inverting a light palette usually fails. The background darkens while the accent stays put and disappears, shadows become invisible and borders vanish. Dark mode is the same palette rearranged under different rules.

Surface layers

In light mode the page background is the lightest surface and cards sit slightly lighter still, or separate through shadow. In dark mode the background is darkest and surfaces are lighter, so a card appears closer to the viewer. The tokens here use background 50 and surface 100 in light, background 950 and surface 900 in dark.

TokenLightDarkWhy
background50950the furthest plane
surface100900one step nearer than the background
text90050maximum contrast with the background
muted700300lower contrast but still 4.5:1
border200800the smallest separation from the background
primary600400two steps lighter in the dark
on primary509504.5:1 against the accent fill

The accent goes lighter

If step 600 is the accent in light mode, step 400 is the accent in dark. Two reasons: at the same chroma colours look duller on a dark background, and step 600 against a 950 background lacks enough contrast, so the button sinks in. That is why the export defaults to 600 light and 400 dark.

Shadows and borders

A black shadow is invisible on a dark background. Depth comes instead from surface lightness and thin light borders, which is why the preview cards here use borders. Borders do not always need 3:1, but where the border carries function, as on an input, it should.

Implementation

:root { color-scheme: light dark; }
:root {
  --bg: light-dark(oklch(97% 0.02 250), oklch(18% 0.03 250));
  --surface: light-dark(oklch(93% 0.02 250), oklch(25% 0.03 250));
  --text: light-dark(oklch(25% 0.04 250), oklch(97% 0.02 250));
  --primary: light-dark(oklch(49% 0.16 250), oklch(68% 0.14 250));
}

Name tokens by role and change only values per theme. A name like --blue-600 that points at step 400 in dark mode is a lie; --color-primary stays true. Role names also keep utility class names stable.

Verification

The token arrangement summarises common dark-mode practice; brand rules take precedence.

Questions

Should dark mode use pure black?

Contrast is highest but glare and smearing appear. A very dark grey, L 15–20%, is usually easier to read.

Why does my accent disappear in the dark?

It lacks contrast against the darker background and looks duller at the same chroma. Move one or two steps lighter.

How do I avoid a flash when the theme changes?

Set data-theme with an inline script before the page paints. That is what the theme boot script here does.

See the light and dark previews side by side in the export tab.

Open the tool

Basis date 28 November 2026. Written against the W3C specifications, the APCA documentation and published browser support tables; updated when they change.

Back to the guides