Skip to main content
Version: Next 🚧

Theme

The ThemeStore loads and manages themes, handles scope-based theme assignment, and applies CSS variables to the DOM. See Theme for a conceptual overview.

Methods​

loadDefaultTheme()​

Loads the default theme for a given scope.

loadDefaultTheme(scope: string, darkMode?: boolean): void
NameTypeRequiredDescription
scopestring✓The scope identifier for which to load the default theme.
darkModebooleanWhether to enable dark mode.

Example

inject(ThemeStore).loadDefaultTheme('main', true);

setCurrentTheme()​

Switches the active theme for a given scope.

setCurrentTheme(scope: string, themeName: string, darkMode?: boolean): void
NameTypeRequiredDescription
scopestring✓The scope identifier.
themeNamestring✓The name of the theme to apply.
darkModebooleanWhether to enable dark mode.

Example

inject(ThemeStore).setCurrentTheme('main', 'ruby', true);

setDarkMode()​

Toggles dark mode for a given scope.

setDarkMode(scope: string, darkMode: boolean): void
NameTypeRequiredDescription
scopestring✓The scope identifier.
darkModeboolean✓true to enable dark mode.

Example

inject(ThemeStore).setDarkMode('main', true);

processCssVars()​

Processes and returns the CSS variables object for a given theme name.

processCssVars(themeName: string): CssVars
NameTypeRequiredDescription
themeNamestring✓The theme name to process.

Returns CssVars — the CSS variables for that theme.

applyThemeToNativeElement()​

Applies theme CSS variables directly to an HTML element.

applyThemeToNativeElement(element: HTMLElement, cssVars?: Record<string, string>): void
NameTypeRequiredDescription
elementHTMLElement✓The DOM element to apply the theme to.
cssVarsRecord<string, string>CSS variable overrides.