Skip to main content

Theme

Overview

This document provides an overview of the ThemeStore and its methods.
See Theme for more information.

loadDefaultTheme()

Loads the default theme for a given scope.

loadDefaultTheme(scope: string, darkMode?: boolean): void
ParameterTypeDescription
scopestringThe scope for the theme.
darkModebooleanOptional. Enable dark mode.

Usage Example:

ThemeStore.loadDefaultTheme('main', true);

setCurrentTheme()

Sets the current theme for a given scope.

setCurrentTheme(scope: string, themeName: string, darkMode?: boolean): void
ParameterTypeDescription
scopestringThe scope for the theme.
themeNamestringThe name of the theme.
darkModebooleanOptional. Enable dark mode.

Usage Example:

ThemeStore.setCurrentTheme('main', 'DarkTheme', true);

setDarkMode()

Sets the dark mode for a given scope.

setDarkMode(scope: string, darkMode: boolean): void
ParameterTypeDescription
scopestringThe scope for the theme.
darkModebooleanEnable or disable dark mode.

Usage Example:

ThemeStore.setDarkMode('main', true);

processCssVars()

Processes the CSS variables for a given theme name.

processCssVars(themeName: string): CssVars
ParameterTypeDescription
themeNamestringThe name of the theme.

Usage Example:

const cssVars = processCssVars('DarkTheme');

themeColorsToCssVariables()

Converts theme colors to CSS variables.

themeColorsToCssVariables(colors: any): any
ParameterTypeDescription
colorsanyThe theme colors object.

Usage Example:

const cssVars = themeColorsToCssVariables(theme.colors);

themeColorNameToCssVariable()

Converts a theme color name to a CSS variable name.

themeColorNameToCssVariable(name: string): string
ParameterTypeDescription
namestringThe name of the color.

Usage Example:

const cssVarName = themeColorNameToCssVariable('primaryColor');

applyThemeToNativeElement()

Applies the theme CSS variables to a native HTML element.

applyThemeToNativeElement(element: HTMLElement, cssVars?: Record<string, string>): void
ParameterTypeDescription
elementHTMLElementThe HTML element.
cssVarsRecord<string, string>Optional. The CSS variables.

Usage Example:

applyThemeToNativeElement(document.body, cssVars.light);