Preview brand Custom

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

  1. Auto (default): follow the device's light or dark setting through prefers-color-scheme.
  2. Choice: picking Light or Dark sets data-theme on the page and saves it on the device.
  3. Before first paint: a tiny inline script reads the saved choice in the page head, so there is no flash of the wrong theme.
  4. 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.