Skip to content

SiThemeService documentation

provided in root

Attributes and Methods

NameTypeDefaultDescription
activeThemeName
Optional
stringThe 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
  • theme: Theme  The theme to be saved.
applyTheme(...)
(theme: Theme, type: ThemeType, overwrite: boolean) => voidApplies the given theme to the document. If no theme is given, the active theme is applied.

Parameters
applyThemeType(...)
(type: ThemeType) => voidApply light or dark theme to the document.

Parameters
deleteTheme(...)
(name: string) => Observable<boolean>Deletes the theme with the given name from the theme store.

Parameters
getActiveTheme()
() => Observable<(undefined | Theme)>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(...)
(name: string) => Observable<(undefined | Theme)>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
  • name: string  The name of the theme to be returned.
hasTheme(...)
(name: string) => booleanReturns true if a theme with the given name is available.

Parameters
isThemeValid(...)
(data: unknown) => booleanChecks if the given theme JSON object is a valid theme.

Parameters
resetPreview()
() => voidResets the preview theme to the default element theme.
(readonly) resolvedColorScheme
(undefined | ThemeType)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<(undefined | Theme)>...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, SafeHtml>>{}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) => voidUpdates the given property of the preview theme.

Parameters

Types Documentation

Properties
dark?: ThemeColorScheme
light?: ThemeColorScheme
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
("dark" | "light" | "auto")

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