Persist a website theme preference.
The exact lowercase value system, light, or dark is written under the project-specific key. The function does not resolve or apply the theme.
system
light
dark
Usage:
import { setThemePreference } from "mazey";const stored = setThemePreference( "MY_WEBSITE_THEME", "dark");console.log(stored); Copy
import { setThemePreference } from "mazey";const stored = setThemePreference( "MY_WEBSITE_THEME", "dark");console.log(stored);
Output when browser storage is available:
true Copy
true
Project-specific local-storage key.
Theme preference to persist.
true when storage succeeds, or false when storage is unavailable or rejects the write.
false
If storageKey is empty or value is not system, light, or dark.
storageKey
value
Safe during SSR. This function writes only the preference and never mutates the DOM, applies a theme, or adds listeners.
Persist a website theme preference.
The exact lowercase value
system,light, ordarkis written under the project-specific key. The function does not resolve or apply the theme.Usage:
Output when browser storage is available: