Theme and settings
The visitor's device decides by default. If they choose otherwise, we remember it, and apply it before anything is drawn.
How it works
- Auto (default): follow the device's light or dark setting through
prefers-color-scheme. - Choice: picking Light or Dark sets
data-themeon the page and saves it on the device. - Before first paint: a tiny inline script reads the saved choice in the page head, so there is no flash of the wrong theme.
- Everything follows: tokens, images that need a dark version, code colours and the favicon in the browser tab.
Rules
- Never ship a component that only works in one theme. Every Somnia DS example renders in both for this reason.
- Print is always light, whatever the setting.
- Settings are presentation only. They're stored on the device, never sent anywhere, and need no cookie consent.