Theme Toggle
hoogin/theme-toggleFreeComponent
A dark/light mode toggle button that uses the theme provider.
Install it
npx shadcn@latest add https://shadcn.hoogin.be/r/theme-toggle.jsonSource
1import { MoonIcon, SunIcon } from "lucide-react"23import { Button } from "@/components/ui/button"4import { useTheme } from "@/hoogin/ui/theme-provider"56export function ThemeToggle() {7 const { theme, setTheme } = useTheme()89 const isDark =10 theme === "dark" ||11 (theme === "system" &&12 window.matchMedia("(prefers-color-scheme: dark)").matches)1314 return (15 <Button16 variant="ghost"17 size="icon"18 aria-label={isDark ? "Switch to light mode" : "Switch to dark mode"}19 onClick={() => setTheme(isDark ? "light" : "dark")}20 >21 {isDark ? <SunIcon /> : <MoonIcon />}22 </Button>23 )24}
What it pulls in
Other registry items
Files it writes
More from hoogin
All 6 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| App Sidebarapp-sidebar | hoogin | Components | Free | no deps · 6 files | |
| Sidebarsidebar | hoogin | Components | Free | no deps | |
| Spinnerspinner | hoogin | Components | Free | no deps | |
| Theme Providertheme-provider | hoogin | Components | Free | no deps |
