beactio-landing/src/components/theme-toggle.tsx
2025-01-13 07:08:59 +07:00

24 lines
678 B
TypeScript

"use client";
import { Button } from "@/components/ui/button";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";
export function ThemeToggle() {
const { setTheme, theme } = useTheme();
// Don't show in production
if (process.env.NODE_ENV === "production") return null;
return (
<Button
variant="ghost"
size="icon"
className="fixed bottom-1 left-1 z-50"
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
>
<Sun className="h-[1.5rem] w-[1.3rem] dark:hidden" />
<Moon className="hidden h-5 w-5 dark:block" />
<span className="sr-only">Toggle theme</span>
</Button>
);
}