API reference
usePreferencesStore
Theme and appearance preferences, stored in cookies.
stores/preferences.ts
usePreferencesStore()
Returns themeName, themeMode, isDark, appearance, isDefaultAppearance and the setters setTheme, toggleTheme, setThemeMode, useSystemTheme, setAppearance, resetOption and resetAppearance.
const usePreferencesStore: SetupStoreDefinition<"preferences", { themeName: any; themeMode: any; isDark: any; appearance: any; isDefaultAppearance: any; hasExplicitTheme: any; setTheme: (name: ThemeName) =>…DEFAULT_APPEARANCE
The defaults of every appearance option.
const DEFAULT_APPEARANCE: AppearancePreferences
APPEARANCE_OPTIONS
The allowed values of every option.
const APPEARANCE_OPTIONS: { readonly primary: ("brand" | "sage" | "blue" | "violet" | "rose" | "amber" | "graphite")[]; readonly menu: readonly ["light", "semi-dark"]; readonly layout: readonly ["vertical"…normalizeAppearance()
Validates a cookie value against the options.
normalizeAppearance(value: unknown): AppearancePreferences
Returns
primarymenulayoutcontentWidthdirectiondensityTHEME_COOKIE_KEY
The theme cookie.
const THEME_COOKIE_KEY: "app-theme"
THEME_RESOLVED_COOKIE_KEY
The cookie with the resolved system theme.
const THEME_RESOLVED_COOKIE_KEY: "app-theme-resolved"
APPEARANCE_COOKIE_KEY
The appearance cookie.
const APPEARANCE_COOKIE_KEY: "app-appearance"