BT-07Buttons
Switch Button
Light and dark theme toggle whose sun folds into a moon while the new theme spreads from the button as a circle.
Usage
With no props, the button toggles the dark class on <html>, which is what Tailwind's class-based dark: variant reads. It does not save the choice.
The new theme spreads out from the button as a circle, using the View Transitions API. In browsers without it, or with reduced motion turned on, the theme switches instantly.
If a theme provider already owns the theme, pass the applied theme and a setter instead. With next-themes:
"use client";
import { useTheme } from "next-themes";
import SwitchButton from "@/components/kokonutui/switch-button";
export function ThemeSwitch() {
const { resolvedTheme, setTheme } = useTheme();
return (
<SwitchButton
onThemeChange={setTheme}
theme={resolvedTheme === "dark" ? "dark" : "light"}
/>
);
}PROPay Button and more like it are in Kokonut UI Pro
Installation
Switch Button is a free, open-source React component in the Kokonut UI Buttons collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/switch-button.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/switch-buttonProps
size"sm" | "default" | "lg"Default "default"showLabelbooleanDefault trueShows "Light" or "Dark" next to the icon.
themeThemeThe applied theme, when a theme provider owns it (for next-themes, its resolvedTheme). Pair it with onThemeChange. Without it the button toggles the dark class on <html> itself.
onThemeChange(theme: Theme) => voidCalled with the theme to switch to.
revealbooleanDefault trueSpreads the new theme from the button as a circle. false switches instantly.
Also takes every prop of React.ButtonHTMLAttributes<HTMLButtonElement>.
Theme
type Theme = "light" | "dark";Dependencies
| Needs | Version | Comes from |
|---|---|---|
cn from lib/utils.ts | shadcn init | |
| React | 19 | Your app |
| Tailwind CSS | 4 | Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.

