"use client"; import { Moon, Sun } from "lucide-react"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; interface ThemeToggleProps { className?: string; showLabel?: boolean; variant?: "ghost" | "outline" | "default"; size?: "default" | "sm" | "lg" | "icon"; } export default function ThemeToggle({ className, showLabel = false, variant = "ghost", size = "icon" }: ThemeToggleProps) { // Start with null to avoid hydration mismatch - theme is set by inline script in layout.tsx const [theme, setTheme] = useState<"light" | "dark" | null>(null); useEffect(() => { // Read the current theme from the DOM (already set by inline script in layout.tsx) const isDark = document.documentElement.classList.contains("dark"); setTheme(isDark ? "dark" : "light"); }, []); const toggleTheme = () => { const newTheme = theme === "light" ? "dark" : "light"; setTheme(newTheme); localStorage.setItem("theme", newTheme); document.documentElement.classList.toggle("dark", newTheme === "dark"); }; return ( ); }