Themes
theme.js applies and remembers the choice of light, dark, or automatic mode.
- theme.themes
type: Array.<string>
Display names of the supported themes.
- theme.theme_icons
type: Array.<string>
Ionic icon names corresponding to
theme.themes.
- theme.get_theme()
Return the persisted theme selection.
- Returns:
string -- Stored lower-case theme name, or null when unset.
Example
localStorage.setItem('pyDIETDefaultTheme', 'dark'); get_theme(); // 'dark'
- theme.update_theme(theme)
Persist and apply a theme selection.
Names containing "dark" enable dark mode; names containing "light" disable it. Other, missing, or non-string values follow the operating-system preference. A truthy value is stored before application.
- Arguments:
theme (string) -- Theme selection, or a falsy value to reuse storage.
- Returns:
void
Example
update_theme('dark'); document.body.classList.contains('dark'); // true