Components / Buttons
Theme Toggle
A light/dark switch that reveals the new theme as a circle growing out of the button.
Click to switch the whole site's theme
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
None. This component only needs React and Tailwind.
- 2
Add the component
Copy the code from the Code tab above into
components/ui/theme-toggle.tsx. - 3
Use it
example.tsximport { ThemeToggle } from "@/components/ui/theme-toggle"; export default function ThemeToggleDemo() { return ( <div className="flex flex-col items-center gap-3"> <ThemeToggle /> <p className="text-sm text-zinc-600 dark:text-zinc-400">Click to switch the whole site's theme</p> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Extra classes for the button. |