@maxhealth.tech/prefab / renderer / createThemeToggle
Function: createThemeToggle()
ts
function createThemeToggle(root, options?): () => void;Defined in: renderer/theme.ts:139
Create a theme toggle button inside a prefab root element.
- Persists to localStorage
- Syncs two-way with
document.documentElement[data-theme]via MutationObserver - Uses sun/moon SVG icons (no external deps)
Parameters
| Parameter | Type |
|---|---|
root | HTMLElement |
options? | ThemeToggleOptions |
Returns
A cleanup function that removes the button and observer.
() => void