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.

PropTypeDefault
className
stringโ€”
storageKey

localStorage key for the choice. Use the same one in ThemeScript.

stringtheme

<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.

PropTypeDefault
storageKey
stringtheme