import { Moon, Sun, Monitor } from "lucide-react"; import { useTheme } from "next-themes"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; /** * Light/dark/system theme toggle. * * We intentionally render a neutral placeholder until `next-themes` has * hydrated — otherwise the first client render disagrees with the server-less * pre-render and the icon briefly flashes the wrong state. */ export function ThemeToggle() { const { theme, setTheme, resolvedTheme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); const isDark = mounted && (resolvedTheme ?? theme) === "dark"; return ( setTheme("light")}> Light {theme === "light" && } setTheme("dark")}> Dark {theme === "dark" && } setTheme("system")}> System {theme === "system" && } ); } export default ThemeToggle;