main
tsx 20 lines 727 Bytes
Raw
1 import { Moon, Sun } from "lucide-react";
2 import { useTheme } from "next-themes";
3 import { Button } from "@/components/ui/button";
4
5 export function ThemeToggle() {
6 const { theme, setTheme } = useTheme();
7
8 return (
9 <Button
10 variant="ghost"
11 size="icon"
12 onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
13 className="relative w-9 h-9 rounded-full hover:bg-secondary-foreground/10"
14 >
15 <Sun className="h-5 w-5 rotate-0 scale-100 transition-all text-primary dark:-rotate-90 dark:scale-0" />
16 <Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all text-primary dark:rotate-0 dark:scale-100" />
17 <span className="sr-only">Toggle theme</span>
18 </Button>
19 );
20 }