Detect and update global theme.
- Source:
Methods
(static) storage() → {string|null}
Returns the current theme value
from the localStorage
or null if not retrievable
- Source:
- See:
Returns:
- Type
- string | null
(static) system() → {'dark'|'light'|null}
Returns the current system theme (light|dark) or null
if none detected.
Uses window.matchMedia
- Source:
- See:
Returns:
- Type
- 'dark' | 'light' | null
(static) update(value)
Updates the global theme to the current document
and saves the decision in localStorage
, if supported by the browser
Parameters:
Name | Type | Description |
---|---|---|
value |
'light' | 'dark' | the new theme to use |
- Source:
- See:
Throws:
-
if value is not supported
- Type
- Error