"use client"; import React from "react"; import { Moon, Sun } from "lucide-react"; import { useTheme } from "next-themes"; import { Button } from "@/components/ui/button"; export default function ThemeToggleButton() { const { setTheme } = useTheme(); function toggleTheme() { // We intentionally read the current state from the DOM class to avoid // hydration-unsafe theme reads during SSR/SSG. :contentReference[oaicite:2]{index=2} const isDark = typeof document !== "undefined" && document.documentElement.classList.contains("dark"); setTheme(isDark ? "light" : "dark"); } return ( ); }