Command Palette

Search for a command to run...

Loading component...

Components free Theme toggle buttons

Theme toggle buttons

Inspired by and adapted from toggles.dev. This implementation is rebuilt in React and Framer Motion, avoiding external toggle packages for seamless theme integration. Use them for implementing dark/light mode switching in your applications with full control over animations and theme state management.

Dependencies

Interaction Type

Animated svg on toogle
Theme does't change on toogle

with shacn cli3.0

//components.json
  "registries": {
    "@skiper-ui": "https://skiper-ui.com//registry/{name}.json"
  }
npx shadcn add @skiper-ui/skiper4

OR with old shacncli

 npx shadcn@latest add https://skiper-ui.com/registry/skiper4.json

How to use

import {
  ThemeToggleButton1,
  ThemeToggleButton2,
  ThemeToggleButton3,
  ThemeToggleButton4,
  ThemeToggleButton5,
} from "@/components/v1/skiper4";

const DemoSkiper4 = () => {
  return (
    <div className="flex items-center justify-center gap-4 p-8">
      <ThemeToggleButton1 className="h-12 w-12" />
      <ThemeToggleButton2 className="h-12 w-12" />
      <ThemeToggleButton3 className="h-12 w-12" />
      <ThemeToggleButton4 className="h-12 w-12" />
      <ThemeToggleButton5 className="h-12 w-12" />
    </div>
  );
};

important note

But the above are just animated icons you can't toggle theme with them if you want to toggle theme with animated useThemeToggle hook from skiper26 that will use view transition api to toggle theme like crazy.

Using useThemeToggle() hook

import { useThemeToggle } from "@/components/v1/skiper26";

const DemoSkiper4 = () => {
  const { isDark, toggleTheme } = useThemeToggle();

  return (
    <div
      onClick={toggleTheme}
      className="flex cursor-pointer items-center justify-center gap-4 p-8"
    >
      <button
        type="button"
        className={cn(
          isDark ? "bg-black text-white" : "bg-white text-black",
          className,
        )}
        onClick={() => setIsDark(!isDark)}
      >
        {
          // destrucure the button as you want here from skiper4 theme toggles and use isDark to toggle the theme or plat with svg
        }
      </button>
    </div>
  );
};

Attribution

  • Learn more about useThemeToggle hook from skiper26
  • Inspired by and adapted from toggles.dev (Open Source CSS Theme Toggles by Alfie Jones)

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 to
Drop 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.