Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
"use client";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
export function ThemeToggle({ className }: { className?: string }) {
const { resolvedTheme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false);
// Avoid hydration mismatch — theme is only known on the client.
useEffect(() => setMounted(true), []);
const isDark = resolvedTheme === "dark";
return (
<Button
variant="ghost"
size="icon"
aria-label={
!mounted
? "Toggle theme"
: isDark
? "Switch to light theme"
: "Switch to dark theme"
}
onClick={() => setTheme(isDark ? "light" : "dark")}
className={cn("rounded-full", className)}
>
{mounted ? (
isDark ? (
<Sun className="size-4" />
) : (
<Moon className="size-4" />
)
) : (
<span className="size-4" />
)}
</Button>
);
}