Theme Toggle
FreeA sun that morphs into a moon and wipes the new theme in from the button.
Installation
pnpm dlx shadcn@latest add @viewport/theme-toggle
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { ThemeToggle } from "@/components/viewport/theme-toggle";
export default function ThemeToggleDemo() {
return (
<div className="flex flex-col items-center gap-3">
<ThemeToggle className="size-12 border border-border [&_svg]:size-5" />
<p className="text-sm text-muted-foreground">The new theme wipes in from the button.</p>
</div>
);
}Accessibility
- The label states the action, e.g. “Switch to dark theme”.
- Skips the wipe under reduced motion or without View Transitions support.