Resolution checks the URL query named by storageKey, local storage under
the same key, the current prefers-color-scheme media query, and finally
the fixed light fallback. Query values accept only light and dark.
Storage also accepts system, which resolves to a concrete value while
retaining the System label. URL query preferences apply only to the
current resolution and are not persisted.
The concrete light or dark value and the label of the preference that selected it.
Throws
If storageKey is not a non-empty string.
Remarks
Safe during SSR and resilient to unavailable or throwing browser APIs. Resolution is read-only: the function never writes storage, mutates the DOM, or adds listeners.
Resolve the current website theme.
Resolution checks the URL query named by
storageKey, local storage under the same key, the currentprefers-color-schememedia query, and finally the fixedlightfallback. Query values accept onlylightanddark. Storage also acceptssystem, which resolves to a concrete value while retaining theSystemlabel. URL query preferences apply only to the current resolution and are not persisted.Resolution matrix:
darklight{ value: "dark", label: "Dark" }lightdark{ value: "light", label: "Light" }dark{ value: "dark", label: "Dark" }light{ value: "light", label: "Light" }system{ value: "dark", label: "System" }system{ value: "light", label: "System" }{ value: "dark", label: "System" }{ value: "light", label: "System" }{ value: "light", label: "Light" }Usage:
Possible output: