Components
Theme Toggle
Switches between the dark and light themes and remembers the choice.
Switch the theme
Import
import { ThemeToggle, ThemeScript } from '@rinzai/zen';API reference
<ThemeToggle>
Switches <html> between the dark and light themes and remembers the choice (localStorage). Add ThemeScript to <head> to apply it on the next visit.
| Prop | Type | Default |
|---|---|---|
className | string | โ |
storageKeylocalStorage key for the choice. Use the same one in ThemeScript. | string | theme |
<ThemeScript>
Put in <head>: applies the remembered theme before the first paint, so a light-theme visitor never sees a dark flash on page load.
| Prop | Type | Default |
|---|---|---|
storageKey | string | theme |