Skip to content

storeDarkMode ​

Overview ​

The store for the current dark mode state, and persisting it.

Usage:

js
  import { storeDarkMode } from "@vueda";
  const darkMode = storeDarkMode();

  darkMode.isDark; // reactive boolean for dark mode, true if dark mode is enabled

  darkMode.init(); // get dark mode from local storage or prefers
  darkMode.toggle(); // toggle dark mode

Signature ​

storeDarkMode(pinia, hot)

Parameters ​

NameTypeRequiredDescription
piniaPinianoPinia instance to retrieve the store
hotStoreGenericnodev only hot module replacement

Returns ​

Store

Properties ​

$id ​

Id of the store. Used by map helpers.

Type: "darkMode"

Source: node_modules/.pnpm/pinia@3.0.4_typescript@5.9.3_vue@3.5.43_typescript@5.9.3_/node_modules/pinia/dist/pinia.d.ts:654

isDark ​

Whether dark mode is on.

Type: boolean

Source: client/lib/stores/storeDarkMode.js:38

Methods ​

  • init - Sets isDark from localStorage.
  • toggle - Flips isDark and saves the new value to localStorage.

Source ​

client/lib/stores/storeDarkMode.js:31