"use client"; import { useEffect, useState } from "react"; import { Moon, Sun } from "lucide-react"; import { useTheme } from "next-themes"; import { motion } from "framer-motion"; export function ThemeToggle() { const [mounted, setMounted] = useState(false); const { theme, setTheme } = useTheme(); // Wait for component to be mounted to avoid hydration mismatch useEffect(() => { setMounted(true); }, []); if (!mounted) { return
Loading theme toggle
; } return setTheme(theme === "dark" ? "light" : "dark")} className="w-8 h-8 sm:w-9 sm:h-9 bg-muted hover:bg-muted/80 rounded-md flex items-center justify-center transition-all" aria-label="Toggle theme"> {theme === "dark" ? : } Toggle theme ; }