Malay Patel

Theme Switch

Component

About

Switches the page theme: the sun pulls in its rays and is eclipsed into a moon while the new theme spreads out from the button. Free component from uibrik (uibrik.com).

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

Code

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

Usage.tsx

"use client";

import { revealTheme, ThemeSwitch } from "@/components/ui/theme-switch";

const props = {
  reveal: "circle" as "circle" | "expand" | "split" | "wipe" | "diagonal" | "blinds" | "blur" | "zoom" | "none",
  revealDuration: 0.5,
  easing: "auto" as "auto" | "out" | "in-out" | "linear",
  wipeFrom: "left" as "left" | "right" | "top" | "bottom",
  corner: "top-left" as "top-left" | "top-right" | "bottom-left" | "bottom-right",
  orientation: "horizontal" as "horizontal" | "vertical",
  slats: 8,
  cascade: 0,
  blurAmount: 8,
  depth: 0.04,
  size: 40,
  radius: 12,
};

export default function Demo() {
  const options = {
    mode: props.reveal,
    duration: props.revealDuration,
    easing: props.easing,
    wipeFrom: props.wipeFrom,
    corner: props.corner,
    orientation: props.orientation,
    slats: props.slats,
    cascade: props.cascade,
    blurAmount: props.blurAmount,
    depth: props.depth,
  };
  return (
    <div className="flex h-screen w-full items-center justify-center">
      <ThemeSwitch
        {...props}
        setTheme={(theme, origin) => {
          // Inside the docs page's preview frame, a reveal would be clipped to
          // the frame. Hand it to the page instead (components/site/ThemeSync),
          // which runs it across the whole site from the button's position.
          if (window.parent !== window) {
            window.parent.postMessage({ type: "theme-reveal", theme, origin, ...options }, location.origin);
          } else {
            revealTheme(theme, { origin, ...options });
          }
        }}
      />
    </div>
  );
}

Dependencies

More by Malay Patel

View all
  • Halftone Horizon

    Halftone Horizon

    52
  • Halftone

    Halftone

    46
  • Fold Toolbar

    Fold Toolbar

    31
  • Balloon Button

    Balloon Button

    31
  • Ascii Field

    Ascii Field

    12
  • Oil Slick

    Oil Slick

    11
  • Hold To Confirm

    Hold To Confirm

    5
  • Copy Button

    Copy Button

    4