Skip to content
← Work log

A theme toggle with no flash

The theme toggle is the first real design-system component on the new site. It's the system's own toggle, but driven by the theme code we already had rather than its own.

That matters because the pages are prerendered. The HTML doesn't know your choice, so without help you'd get a flash of the wrong theme on every load. A tiny script at the top of <head> reads the saved choice and applies it before anything gets drawn, and the tokens use light-dark() so "system" just follows the OS with no script at all.

Wiring the toggle into that, instead of letting it manage its own state, also cleared up a hydration warning that had been sitting there since the foundation went in.

design-systemthemingssr
AI-OMETER— DISCLOSURE INDEX
CO-WRITTEN60%