Skip to main content
Glama
theme-toggle.tsx1.08 kB
"use client" import { Moon, Sun } from "lucide-react" import { useTheme } from "next-themes" import { Button } from "@/components/ui/button" import { useEffect, useState } from "react" export function ThemeToggle() { const { theme, setTheme } = useTheme() const [mounted, setMounted] = useState(false) // Avoid hydration mismatch by only rendering after mount useEffect(() => { setMounted(true) }, []) if (!mounted) { return ( <Button variant="outline" size="icon" className="w-10 h-10"> <span className="sr-only">Toggle theme</span> </Button> ) } const toggleTheme = () => { setTheme(theme === "dark" ? "light" : "dark") } return ( <Button variant="outline" size="icon" onClick={toggleTheme} className="w-10 h-10"> <Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> <Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> <span className="sr-only">Toggle theme</span> </Button> ) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/myeong-ga/research-agent-mcp-0.36-pro-preview-06-01'

If you have feedback or need assistance with the MCP directory API, please join our Discord server