nui-theme-provider
nrjdalal/nui-theme-providerFreeComponent
acme publishes no description for this item.
Install it
npx shadcn@latest add https://nrjdalal.dev/r/nui-theme-provider.jsonSource
1"use client"23import { Button } from "@/components/ui/button"4import { RiMoonFill, RiSunFill } from "@remixicon/react"5import { ThemeProvider as NextThemesProvider, useTheme } from "next-themes"67export const ThemeToggle = () => {8 const { theme, setTheme } = useTheme()910 const smartToggle = () => {11 /* The smart toggle by @nrjdalal */12 const prefersDarkScheme = window.matchMedia(13 "(prefers-color-scheme: dark)",14 ).matches15 if (theme === "system") {16 setTheme(prefersDarkScheme ? "light" : "dark")17 } else if (18 (theme === "light" && !prefersDarkScheme) ||19 (theme === "dark" && prefersDarkScheme)20 ) {21 setTheme(theme === "light" ? "dark" : "light")22 } else {23 setTheme("system")24 }25 }2627 return (28 <Button29 variant="ghost"30 className="aspect-square size-full rounded-none [&_svg]:size-5"31 onClick={smartToggle}32 aria-label="Switch between system/light/dark version"33 >34 <RiSunFill className="dark:hidden" aria-hidden="true" />35 <RiMoonFill className="hidden dark:block" aria-hidden="true" />36 </Button>37 )38}3940export const ThemeProvider = ({41 children,42 ...props43}: React.ComponentProps<typeof NextThemesProvider>) => {44 return (45 <NextThemesProvider46 attribute="class"47 defaultTheme="system"48 enableSystem49 disableTransitionOnChange50 {...props}51 >52 {children}53 </NextThemesProvider>54 )55}
What it pulls in
npm packages
Files it writes
More from acme
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | acme | Components | Free | 5 deps · 2 files | |
| alertalert | acme | Components | Free | 4 deps · 2 files | |
| alert-dialogalert-dialog | acme | Components | Free | 6 deps · 3 files | |
| aspect-ratioaspect-ratio | acme | Components | Free | 1 dep | |
| avataravatar | acme | Components | Free | 4 deps · 2 files | |
| badgebadge | acme | Components | Free | 5 deps · 2 files | |
| breadcrumbbreadcrumb | acme | Components | Free | 5 deps · 2 files | |
| buttonbutton | acme | Components | Free | 5 deps · 2 files |
