Command Palette
Search for a command to run...
Loading component...
Theme toggle btn
Advanced theme toggle component with View Transition API animations. Features multiple animation variants including circle, circle-blur, bottom-up, and GIF-based transitions.
Dependencies
Interaction Type
| Toggle theme with animated transitions | |
| Drag options panel to reposition | |
| Change animation variants and GIFs |
npx shadcn add @skiper-ui/skiper26Manual setup
pnpm install next-themes
create theme provider
// components/theme-provider.tsx "use client"; import * as React from "react"; import { ThemeProvider as NextThemesProvider } from "next-themes"; export function ThemeProvider({ children, ...props }: React.ComponentProps<typeof NextThemesProvider>) { return <NextThemesProvider {...props}>{children}</NextThemesProvider>; }
Wrap your app with the theme provider
// app/layout.tsx import { ThemeProvider } from "@/components/theme-provider"; export default function RootLayout({ children }: RootLayoutProps) { return ( <> <html lang="en" suppressHydrationWarning> <head /> <body> <ThemeProvider attribute="class" defaultTheme="system" enableSystem> {children} </ThemeProvider> </body> </html> </> ); }
Use the skiper theme toggle
// Using just the theme toggle button const SimpleToggle = () => { return ( <div className="flex items-center justify-center p-8"> <ThemeToggleButton variant="circle" start="center" /> </div> ); };
// Using the custom hook for advanced control const CustomToggle = () => { const { isDark, toggleTheme } = useThemeToggle({ variant: "rectangle", start: "bottom-up", }); return ( <button onClick={toggleTheme} className="rounded bg-blue-500 px-4 py-2 text-white" > Toggle Theme </button> ); };
// Dark or Light mode only const CustomToggle2 = () => { const { setCrazyDarkTheme, setCrazyLightTheme , isDark } = useThemeToggle({ variant: "rectangle", start: "bottom-up", }); return ( <div className="flex gap-2"> { isDark?( <button onClick={setCrazyDarkTheme} className="rounded bg-blue-500 px-4 py-2 text-white" > Dark Mode </button> ):( <button onClick={setCrazyLightTheme} className="rounded bg-blue-500 px-4 py-2 text-white" > Light Mode </button> ) </div> } ); };
Props | Description |
|---|
GIF Animation
<ThemeToggleButton variant="gif" gifUrl="https://media.giphy.com/media/your-gif.gif" />
Customize the gif url
You can find some awesome gifs at giphy and use them in your project. remember use the high contrast gif.
Attribution
- Utilizing View Transition API
- Inspired by and adapted from rudrodip/theme-toggle-effect.
- Refer skiper4 for more button variants.
Source code
Click on the top right to view the source code
Keep in mind
Most components here are recreations of the best out there. I don't claim to be the original creator. This is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone, but if I missed something, let me know.
Contact
Additionlly, if you find any bug or issue, feel free toDrop a dm.
License & Usage:
- Free to use and modify in both personal and commercial projects.
- Attribution to Skiper UI is required when using the free version.
- No attribution required with Skiper UI Pro.