Skip to content

ThemeEngine

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/packages/theme-engine/src/lib/theme-engine.ts

ThemeEngine - A framework-agnostic theming system for Atloria

Features:

  • CSS Variables-based theming
  • Dark/Light mode support
  • localStorage persistence
  • System preference detection
  • SSR support (no flash of unstyled content)
  • Cross-tab synchronization
  • White-label support via custom tokens

Methods

MethodSignatureReturns
setModesetMode(mode: ThemeMode)void
getModegetMode()ThemeMode
getEffectiveThemeModegetEffectiveThemeMode()`'light'
enableDarkModeenableDarkMode()void
disableDarkModedisableDarkMode()void
toggleDarkModetoggleDarkMode()void
useSystemPreferenceuseSystemPreference()void
getThemegetTheme()ThemeTokens
updateThemeupdateTheme(updates: Partial<ThemeTokens>)void
subscribesubscribe(listener: ThemeEventListener)() => void
getSSRScriptgetSSRScript(config: ThemeConfig)string
destroydestroy()void

Where it refuses work

  • ThemeEngine stops the work with an early return when !this.isClient, in 7 places.
  • ThemeEngine stops the work with an early return when stored === 'light' || stored === 'dark' || stored === 'system'.
  • ThemeEngine stops the work with an early return when !this.isClient || !this.config.enablePersistence.
  • ThemeEngine stops the work with an early return when this.currentMode === mode.

Was this page helpful?

Download as PDF