"use client"; import * as React from "react"; import { Moon, Sun } from "lucide-react"; import { useTheme } from "next-themes"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; export function ModeToggle() { const { theme, setTheme, resolvedTheme } = useTheme(); const mounted = React.useSyncExternalStore( () => () => {}, () => true, () => false ); // If not mounted, do not render anything to avoid mismatch if (!mounted) { return (
); } const activeTheme = theme === "system" || !theme ? resolvedTheme : theme; const handleToggle = (value: string) => { if (!value) return; setTheme(value); }; return ( ); }