Constructs the ThemeBaseService.
The global document object.
The MediaMatcher service used to match media queries.
Protected
Readonly
darkMedia query used to detect if the user's system prefers a dark theme.
Protected
Readonly
documentThe global document object.
Protected
Readonly
mediaThe MediaMatcher service used to match media queries.
Readonly
storageInlineStorage instance that manages the current theme in local storage.
The theme is stored with a key of 'theme'
, and
the default theme is the first element in THEMES.
Readonly
themeEventEmitter that triggers whenever the theme changes.
Subscribers can use this to react to theme changes in real-time.
The value of the [data-bs-theme]
attribute
from the <html>
element.
Sets the theme in the [data-bs-theme]
attribute of the <html>
element.
The new theme to set. Must be one of the THEMES.
Protected
htmlThe <html>
HTML element of the document.
true
if the current theme is set
to auto
; otherwise, false
.
true
if the current theme is dark; otherwise, false
.
true
if the current theme is light; otherwise, false
.
The current theme, validated against the available themes.
If the stored theme is not in THEMES, it falls back to the default theme.
Changes the current theme.
The new theme to apply. Must be one of the THEMES.
Protected
setSets the theme and updates the [data-bs-theme]
attribute of the <html>
element.
This method ensures that the theme is stored in local storage and applies the appropriate theme based on the current settings and system preferences.
The theme to set. Must be one of the THEMES.
Service for managing the application's theme.
This service is responsible for storing the selected theme in local storage and applying it to the application. It also supports live theme changes based on user preference or system settings.
This service is best used in conjunction with a Bootstrap-based application that supports both light and dark themes.
Usage: