Mark Yo

Theme Toggle

Component

About

A light/dark switch for next-themes that animates the whole page change with the View Transition API: wipe the new theme in as a rectangle from a corner, center or bottom, grow a sharp or blurred circle, or open it like window blinds.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Theme Toggle to your project and fits it to your theme.

Code

How Theme Toggle is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import { ThemeProvider } from "next-themes"
import { ThemeToggle, type ThemeVariant } from "@/components/ui/karaui-theme-toggle"

const VARIANTS: { variant: ThemeVariant; label: string }[] = [
  { variant: "rectangle", label: "Rectangle" },
  { variant: "circle", label: "Circle" },
  { variant: "circle-blur", label: "Circle blur" },
  { variant: "blinds", label: "Blinds" },
];

export default function ThemeTogglePreview() {
  return (
    <ThemeProvider attribute="class" defaultTheme="dark" enableSystem={false}>
    <div className="flex h-full w-full items-center justify-center gap-5">
      {VARIANTS.map(({ variant, label }) => (
        <div key={variant} className="flex flex-col items-center gap-2">
          <ThemeToggle
            variant={variant}
            start="bottom-up"
            className="rounded-xl border border-border bg-background p-2.5"
            iconClassName="h-5 w-5"
          />
          <span className="text-[11px] text-muted-foreground">{label}</span>
        </div>
      ))}
    </div>
    </ThemeProvider>
  );
}

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    73
  • Pricing Table

    Pricing Table

    33
  • Approval Queue

    Approval Queue

    24
  • Bento Grid

    Bento Grid

    22
  • Expandable Tabs

    Expandable Tabs

    19
  • Image Gallery

    Image Gallery

    17
  • Wallet Card

    Wallet Card

    16
  • Donut Chart

    Donut Chart

    14