Spaces:
No application file
No application file
Download components/theme-toggle.tsx from Humbl3m33/WEB.BUILDING.GENIOUS: direct link, hf CLI and curl.
- Browser
- Download file 621 Bytes
-
https://huggingface.co/spaces/Humbl3m33/WEB.BUILDING.GENIOUS/resolve/91c3f7c754992d1caa2b446031ccec9309b41e54/components/theme-toggle.tsx
- Command line
-
hf download hf://spaces/Humbl3m33/WEB.BUILDING.GENIOUS@91c3f7c754992d1caa2b446031ccec9309b41e54/components/theme-toggle.tsx
-
curl -L -o theme-toggle.tsx https://huggingface.co/spaces/Humbl3m33/WEB.BUILDING.GENIOUS/resolve/91c3f7c754992d1caa2b446031ccec9309b41e54/components/theme-toggle.tsx
621 Bytes
| "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) | |
| useEffect(() => { | |
| setMounted(true) | |
| }, []) | |
| if (!mounted) { | |
| return null | |
| } | |
| return ( | |
| <Button variant="outline" size="sm" onClick={() => setTheme(theme === "light" ? "dark" : "light")}> | |
| {theme === "light" ? <Moon className="h-4 w-4" /> : <Sun className="h-4 w-4" />} | |
| </Button> | |
| ) | |
| } | |