MCPcopy Create free account
hub / github.com/alanagoyal/docbase / ThemeToggle

Function ThemeToggle

components/theme-toggle.tsx:9–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import { Button } from "@/components/ui/button"
8
9export function ThemeToggle() {
10 const { setTheme, theme } = useTheme()
11 const [mounted, setMounted] = React.useState(false)
12
13 React.useEffect(() => {
14 setMounted(true)
15 }, [])
16
17 if (!mounted) {
18 return null
19 }
20
21 return (
22 <Button
23 variant="ghost"
24 size="sm"
25 onClick={() => setTheme(theme === "light" ? "dark" : "light")}
26 >
27 {theme === "dark" ? (
28 <Sun className="h-5 w-5 rotate-0 scale-100 transition-all" />
29 ) : (
30 <Moon className="h-5 w-5 rotate-0 scale-100 transition-all" />
31 )}
32 <span className="sr-only">Toggle theme</span>
33 </Button>
34 )
35}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected