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
| Method | Signature | Returns |
|---|---|---|
setMode | setMode(mode: ThemeMode) | void |
getMode | getMode() | ThemeMode |
getEffectiveThemeMode | getEffectiveThemeMode() | `'light' |
enableDarkMode | enableDarkMode() | void |
disableDarkMode | disableDarkMode() | void |
toggleDarkMode | toggleDarkMode() | void |
useSystemPreference | useSystemPreference() | void |
getTheme | getTheme() | ThemeTokens |
updateTheme | updateTheme(updates: Partial<ThemeTokens>) | void |
subscribe | subscribe(listener: ThemeEventListener) | () => void |
getSSRScript | getSSRScript(config: ThemeConfig) | string |
destroy | destroy() | void |
Where it refuses work
ThemeEnginestops the work with an early return when!this.isClient, in 7 places.ThemeEnginestops the work with an early return whenstored === 'light' || stored === 'dark' || stored === 'system'.ThemeEnginestops the work with an early return when!this.isClient || !this.config.enablePersistence.ThemeEnginestops the work with an early return whenthis.currentMode === mode.
Was this page helpful?