# SiThemeService documentation

**Kind:** class

**Provided in:** `root`

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

```
undecorated_class SiThemeService
```

#### Attributes and Methods

##### activeThemeName

[Source for activeThemeName](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L78-L78>)

**Modifiers:** optional

**Type:** `string`

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

##### addOrUpdateTheme

[Source for addOrUpdateTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L195-L215>)

Adds or updates the given theme in the theme store.

Returns: `true` if the theme was saved successfully.

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

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [theme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L195-L195>) | `Theme` |  | • The theme to be saved. |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)`>`

##### applyTheme

[Source for applyTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L323-L334>)

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

```
applyTheme(theme?: Theme, type?: ThemeType, overwrite?: boolean): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [theme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L323-L323>) (optional) | `Theme` |  |  |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L323-L323>) (optional) | `ThemeType` |  |  |
| [overwrite](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L323-L323>) (optional) | `boolean` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### applyThemeType

[Source for applyThemeType](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L303-L318>)

Apply `light` or `dark` theme to the configured theme target.

```
applyThemeType(type: ThemeType): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L303-L303>) | `ThemeType` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### deleteTheme

[Source for deleteTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L220-L242>)

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

```
deleteTheme(name: string): Observable<boolean>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L220-L220>) | `string` |  |  |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)`>`

##### getActiveTheme

[Source for getActiveTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L172-L188>)

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.

```
getActiveTheme(): Observable<Theme | undefined>
```

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[Theme](<index.html#t:Theme>)`  |  `[undefined](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined>)`>`

##### getTheme

[Source for getTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L148-L166>)

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`.

```
getTheme(name: string): Observable<Theme | undefined>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L148-L148>) | `string` |  | • The name of the theme to be returned. |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[Theme](<index.html#t:Theme>)`  |  `[undefined](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined>)`>`

##### hasTheme

[Source for hasTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L138-L140>)

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

```
hasTheme(name: string): boolean
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L138-L138>) | `string` |  |  |

**Returns:** [boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)

##### isThemeValid

[Source for isThemeValid](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L352-L364>)

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

```
isThemeValid(data: unknown): boolean
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [data](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L352-L352>) | `unknown` |  |  |

**Returns:** [boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)

##### resetPreview

[Source for resetPreview](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L247-L250>)

Resets the preview theme to the default element theme.

```
resetPreview(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### resolvedColorScheme

[Source for resolvedColorScheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L44-L46>)

**Modifiers:** readonly

**Type:** `ThemeType | undefined`

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

##### resolvedColorScheme$

[Source for resolvedColorScheme$](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L40-L40>)

**Modifiers:** readonly

**Type:** `Observable<keyof ThemeColorSchemes>`

**Default:** `this.resolvedColorSchemeSub.asObservable()`

Emits events when the color scheme changes.

##### setActiveTheme

[Source for setActiveTheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L255-L298>)

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

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

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L255-L255>) (optional) | `string` |  |  |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L255-L255>) (optional) | `ThemeType` |  |  |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)`>`

##### themeChange

[Source for themeChange](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L73-L73>)

**Modifiers:** readonly

**Type:** `EventEmitter<Theme | undefined>`

**Default:** `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.

##### themeIcons

[Source for themeIcons](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L86-L86>)

**Modifiers:** readonly

**Type:** `WritableSignal<Record<string, string>>`

**Default:** `{}`

Icon overrides by the currently activeTheme.

##### themeNames

[Source for themeNames](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L63-L65>)

**Modifiers:** readonly

**Type:** `string[]`

All available theme names, including element theme name.

##### themeNames$

[Source for themeNames$](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L58-L58>)

**Modifiers:** readonly

**Type:** `Observable<string[]>`

**Default:** `this.themeNamesSub.asObservable()`

Emits events when the list of available theme names changes.

##### updateProperty

[Source for updateProperty](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L339-L347>)

Updates the given property of the preview theme.

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

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L339-L339>) | `string` |  |  |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L339-L339>) | `string` |  |  |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.service.ts#L339-L339>) | `keyof ThemeColorSchemes` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### Types Documentation

### [Theme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L25-L43>)

**Kind:** interface

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

```
interface Theme
```

#### Properties

<table>     <thead>       <tr>         <th>Name</th>         <th>Type</th>         <th>Description</th>       </tr>     </thead>     <tbody>         <tr id="t:Theme.icons">           <td class="api-column-name">                           <a href="https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L42-L42">icons</a> (optional)          </td>           <td class="api-column-type">             <code>Record&lt;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code>           </td>           <td class="api-column-description"><p>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.</p><p>Example:</p><pre><code class="language-ts">{&#10;  elementUser: &quot;data:image/svg+xml;utf8,&lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'&gt;...&lt;/svg&gt;&quot;&#10;}</code></pre></td>         </tr>         <tr id="t:Theme.name">           <td class="api-column-name">                           <a href="https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L26-L26">name</a>           </td>           <td class="api-column-type">             <code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>           </td>           <td class="api-column-description"></td>         </tr>         <tr id="t:Theme.schemes">           <td class="api-column-name">                           <a href="https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L27-L27">schemes</a>           </td>           <td class="api-column-type">             <code><a href="index.html#t:ThemeColorSchemes">ThemeColorSchemes</a></code>           </td>           <td class="api-column-description"></td>         </tr>     </tbody>   </table>

### [ThemeColorSchemes](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L45-L48>)

**Kind:** interface

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

```
interface ThemeColorSchemes
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [dark](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L47-L47>) (optional) | `ThemeColorScheme` |  |
| [light](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L46-L46>) (optional) | `ThemeColorScheme` |  |

### [ThemeType](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L54-L54>)

**Kind:** type alias

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

```
type ThemeType = ColorScheme | 'auto'
```

### [ThemeColorScheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L50-L50>)

**Kind:** type alias

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

```
type ThemeColorScheme = { [key: string]: string }
```

#### Index Signatures

| Name | Type | Description |
| --- | --- | --- |
| [\[key: string\]](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L50-L50>) | `string` |  |

### [ColorScheme](<https://github.com/siemens/element/blob/main/projects/element-ng/theme/si-theme.model.ts#L52-L52>)

**Kind:** type alias

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

```
type ColorScheme = 'light' | 'dark'
```
