Template
Build Vertex AI gateway landing page
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"use client"
|
||||
|
||||
import { Moon, Sun } from "lucide-react"
|
||||
import { useTheme } from "next-themes"
|
||||
import { useSyncExternalStore } from "react"
|
||||
|
||||
const emptySubscribe = () => () => {}
|
||||
|
||||
export function ThemeToggle() {
|
||||
const mounted = useSyncExternalStore(emptySubscribe, () => true, () => false)
|
||||
const { resolvedTheme, setTheme } = useTheme()
|
||||
|
||||
const isDark = mounted && resolvedTheme === "dark"
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={mounted ? `Switch to ${isDark ? "light" : "dark"} theme` : "Toggle theme"}
|
||||
className="inline-flex size-9 items-center justify-center rounded-full border bg-background/80 text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/60"
|
||||
onClick={() => setTheme(isDark ? "light" : "dark")}
|
||||
>
|
||||
{mounted ? (
|
||||
isDark ? <Sun className="size-4" /> : <Moon className="size-4" />
|
||||
) : (
|
||||
<span className="size-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user