Theme Toggle
A light and dark switch drawn as a dot-matrix sun and moon. Press it and the new theme sweeps across the page as a dither or a band of type.
Needs: None. Sets data-theme on <html>; your CSS reads it (ml-ui's styles do, falling back to prefers-color-scheme).
Customize
effect
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| effect | "dither" | "ascii" | "dither" | How the new theme sweeps across the page: a dithered front, or a band of type. |
| cell | number | 6 | Cell size of the sweep in px. |
| duration | number | 0.9 | Seconds for the whole sweep, across and away. |
| glyphs | string | " .:-=+*#%@" | Characters across the band of type, faint to dense (ascii). |
| storageKey | string | "theme" | Where the choice is remembered in localStorage. Empty to not remember it. |
| onChange | (theme: "light" | "dark") => void | – | Called with the new theme once the page has switched. |
| className | string | – | Class on the button. |
| style | CSSProperties | – | Style on the button. |