The switch is a small firebox with a real flame in it. Flip it and fire catches at the switch and runs across the page, leaving your dark theme behind it. Flip it back and the light opens out again. It works with any site that themes with a data attribute or a dark class.
npx shadcn@latest add https://clickworks.dev/r/burn-switch.jsonThe files land in components/clickworks/burn-switch/. No other packages are added.
import { BurnSwitch } from "@/components/clickworks/burn-switch/react/BurnSwitch"
export function ThemeToggle() {
return <BurnSwitch storageKey="theme" />
}Start in this theme. Leave it out to read it from the page or the saved choice.
Selector of the element that carries the theme.
Default "html"
Attribute set on the target. "class" toggles a dark class instead.
Default "data-theme"
Remembers the choice in localStorage under this key.
Milliseconds for the fire to cross the page.
Default 2600
Synthesized fire sounds.
Default false
Width in px. Everything scales with it.
Default 116
Accessible name of the switch.
Default "Dark mode"
The new theme is fully in place.
The burn reads your page's own colours, so the char melts into whatever background your dark theme paints. Nothing to configure.