website/components/ThemeToggle.tsx

23 lines
742 B
TypeScript
Raw Normal View History

"use client";
2025-11-06 12:02:10 +00:00
import { Moon, Sun } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useAppTheme } from "@/components/ThemeProvider";
2025-11-06 12:02:10 +00:00
export function ThemeToggle() {
const { theme, toggleTheme } = useAppTheme();
2025-11-06 12:02:10 +00:00
return (
<Button
variant="ghost"
size="icon"
onClick={toggleTheme}
className="relative rounded-full cursor-pointer hover:bg-transparent transition-colors"
2025-11-06 12:02:10 +00:00
aria-label="Toggle theme"
>
<Sun className={`h-5 w-5 transition-all absolute ${theme === "light" ? "rotate-0 scale-100" : "rotate-90 scale-0"}`} />
<Moon className={`h-5 w-5 transition-all absolute ${theme === "dark" ? "rotate-0 scale-100" : "rotate-90 scale-0"}`} />
</Button>
);
}