Skip to content

SiThemeService documentation

import { SiThemeService } from '@siemens/element-ng/theme';

Attributes and Methods

Name Type Default Description
activeThemeName optional
string

The name of the theme that is active. Theme name element is the default.

addOrUpdateTheme()
(theme: Theme) => Observable<boolean>

Adds or updates the given theme in the theme store.

Returns: true if the theme was saved successfully.

Parameters
applyTheme()
(theme?: Theme, type?: ThemeType, overwrite?: boolean) => void

Applies the given theme to the configured theme target. If no theme is given, the active theme is applied.

Parameters
applyThemeType()
(type: ThemeType) => void

Apply light or dark theme to the configured theme target.

Parameters
deleteTheme()
(name: string) => Observable<boolean>

Deletes the theme with the given name from the theme store.

Parameters
getActiveTheme()

Loads and returns the currently active theme. Returns undefined if no custom theme is used.

Returns: A custom theme or undefined if the default element theme is used.

getTheme()

Returns a clone of the theme with the given name or undefined if not available or name is element.

Returns: The theme with the given name and undefined if name is element.

Parameters
  • • The name of the theme to be returned.

    name : string

hasTheme()
(name: string) => boolean

Returns true if a theme with the given name is available.

Parameters
isThemeValid()
(data: unknown) => boolean

Checks if the given theme JSON object is a valid theme.

Parameters
resetPreview()
() => void

Resets the preview theme to the default element theme.

(readonly)resolvedColorScheme
ThemeType | undefined

The current color scheme. (e.g. light or dark).

(readonly)resolvedColorScheme$
Observable<keyof ThemeColorSchemes> this.resolvedColorSchemeSub.asObservable()

Emits events when the color scheme changes.

setActiveTheme()
(name?: string, type?: ThemeType) => Observable<boolean>

Sets the active theme to the given name. If no name is given, the default element theme is used.

Parameters
(readonly)themeChange
EventEmitter<Theme | undefined> new EventEmitter<Theme | undefined>()

Emits events when the currently applied theme changes. Either by changing to another theme or by re-applying a theme with updated properties. When switching to default theme element, undefined is emitted.

(readonly)themeIcons
WritableSignal<Record<string, string>> {}

Icon overrides by the currently activeTheme.

(readonly)themeNames
string[]

All available theme names, including element theme name.

(readonly)themeNames$
Observable<string[]> this.themeNamesSub.asObservable()

Emits events when the list of available theme names changes.

updateProperty()
(name: string, value: string, type: keyof ThemeColorSchemes) => void

Updates the given property of the preview theme.

Parameters

Types Documentation

import type { Theme } from '@siemens/element-ng/theme';
Properties
  • A map of icons that overrides the default Element icons. The key must be the key of the original icon that should be overridden. The value has to be a data SVG string.

    Example:

    {
      elementUser: "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>...</svg>"
    }
    

    icons ? : Record<string, string>

  • name : string

  • schemes : ThemeColorSchemes

import type { ThemeColorSchemes } from '@siemens/element-ng/theme';

import type { ThemeType } from '@siemens/element-ng/theme';

import type { ThemeColorScheme } from '@siemens/element-ng/theme';
Index Signatures

ColorScheme

'light' | 'dark'
type alias
import type { ColorScheme } from '@siemens/element-ng/theme';


Except where otherwise noted, content on this site is licensed under MIT License.