mazey
    Preparing search index...

    Function setThemePreference

    • 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.

      Usage:

      import { setThemePreference } from "mazey";

      const stored = setThemePreference(
      "MY_WEBSITE_THEME",
      "dark"
      );

      console.log(stored);

      Output when browser storage is available:

      true
      

      Parameters

      • storageKey: string

        Project-specific local-storage key.

      • value: ThemePreference

        Theme preference to persist.

      Returns boolean

      true when storage succeeds, or false when storage is unavailable or rejects the write.

      If storageKey is empty or value is not system, light, or dark.

      Safe during SSR. This function writes only the preference and never mutates the DOM, applies a theme, or adds listeners.