{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "theme-switcher", "title": "Theme Switcher", "author": "ncdai ", "description": "Toggle between system, light, and dark themes in Next.js apps.", "dependencies": [ "next-themes", "lucide-react", "motion" ], "files": [ { "path": "src/registry/components/theme-switcher/theme-switcher.tsx", "content": "\"use client\"\n\nimport { MonitorIcon, MoonStarIcon, SunIcon } from \"lucide-react\"\nimport { motion } from \"motion/react\"\nimport { useTheme } from \"next-themes\"\nimport type { JSX } from \"react\"\nimport { useSyncExternalStore } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction ThemeOption({\n icon,\n value,\n isActive,\n onClick,\n}: {\n icon: JSX.Element\n value: string\n isActive?: boolean\n onClick: (value: string) => void\n}) {\n return (\n onClick(value)}\n >\n {icon}\n\n {isActive && (\n \n )}\n \n )\n}\n\nconst THEME_OPTIONS = [\n {\n icon: ,\n value: \"system\",\n },\n {\n icon: ,\n value: \"light\",\n },\n {\n icon: ,\n value: \"dark\",\n },\n]\n\nfunction ThemeSwitcher() {\n const { theme, setTheme } = useTheme()\n\n const isMounted = useSyncExternalStore(\n () => () => {},\n () => true,\n () => false\n )\n\n if (!isMounted) {\n return
\n }\n\n return (\n \n {THEME_OPTIONS.map((option) => (\n \n ))}\n \n )\n}\n\nexport { ThemeSwitcher }\n", "type": "registry:component" } ], "docs": "https://chanhdai.com/components/theme-switcher", "type": "registry:component" }