Skip to main content
Version: 11.14.0

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
scopestringThe 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
scopestringThe scope identifier.
themeNamestringThe 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
scopestringThe scope identifier.
darkModebooleantrue 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
themeNamestringThe 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
elementHTMLElementThe DOM element to apply the theme to.
cssVarsRecord<string, string>CSS variable overrides.