The setting
option.color_scheme holds:
Apply the mode before paint
Resolve the mode in the document head, so there’s no flash of the wrong theme:snippets/js.twig
<html data-mode="dark">, which is what your CSS keys off.
Define the palette
Declare colors as space-separated RGB channels, so Tailwind can apply opacity to them:snippets/css.twig
tailwind.config.js
darkMode bound to the attribute, dark: variants work as usual:
The switcher
Show a toggle only when more than one mode is available:mode-switcher element flips localStorage.mode and updates document.documentElement.dataset.mode, so the choice survives navigation.
Using the configured accent
The accent color is exposed ready to drop into a variable:The bundled themes ship fixed palettes and ignore the accent setting. Reading it makes your theme adjustable from the admin panel without a rebuild, which is usually what customers expect.
Checklist
The mode is applied in the head, before the body renders.
Only the configured modes are reachable, and the switcher hides when there’s one.
Both modes are checked for contrast, including borders and dimmed text.
Images and logos have dark variants where they need them, for example
option.brand.logo_dark.The choice persists across page loads.