BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/UI Components/theme-switch

Theme Switch Button

ui-components/theme-switch
FreeBlock

A theme switch component to toggle between light and dark mode.

Install it

npx shadcn@latest add https://ui.raulcarini.dev/r/theme-switch.json

Source

registry/theme-switch/theme-switch.tsxui.raulcarini.dev/r/theme-switch.json
1"use client";
2
3import { MoonIcon, SunIcon } from "lucide-react";
4import { Button } from "@/components/ui/button";
5import { useTheme } from "next-themes";
6import { useCallback } from "react";
7import { cn } from "@/lib/utils";
8
9const ThemeSwitch = ({
10 className,
11 ...props
12}: React.HTMLAttributes<HTMLButtonElement>) => {
13 const { theme, setTheme } = useTheme();
14
15 const handleToggleTheme = useCallback(() => {
16 const newTheme = theme === "light" ? "dark" : "light";
17 setTheme(newTheme);
18 }, [theme, setTheme]);
19
20 return (
21 <Button
22 size="icon"
23 variant="ghost"
24 className={cn("size-8 group", className)}
25 aria-label="Toggle theme between light and dark mode"
26 onClick={handleToggleTheme}
27 {...props}
28 >
29 <MoonIcon
30 className="hidden dark:block fill-transparent group-hover:fill-foreground group-hover:rotate-12 group-hover:scale-110 transition-all duration-200 ease-out"
31 aria-hidden="true"
32 />
33 <SunIcon
34 className="dark:hidden fill-transparent group-hover:fill-foreground group-hover:rotate-12 group-hover:scale-110 transition-all duration-200 ease-out"
35 aria-hidden="true"
36 />
37 </Button>
38 );
39};
40
41export default ThemeSwitch;

What it pulls in

npm packages

  • lucide-react
  • next-themes

Other registry items

  • button

Files it writes

  • registry/theme-switch/theme-switch.tsx

Facts

Registry
UI Components
Type
registry:block
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-04
Last confirmed
today

Go to the source

ui.raulcarini.dev R4ULtv/ui on GitHub Raw registry item This item as JSON

More from UI Components

All 25 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
GitHub Contributionsgithub-contributionsUI ComponentsBlocksFreeno deps
GitHub Contributions Advancedgithub-contributions-advancedUI ComponentsBlocksFreeno deps
GitHub Contributions Advanced Fetchergithub-contributions-advanced-fetcherUI ComponentsBlocksFreeno deps
GitHub Contributions Fetchergithub-contributions-fetcherUI ComponentsBlocksFreeno deps
GitHub Forksgithub-forksUI ComponentsBlocksFree1 dep
GitHub Issuesgithub-issuesUI ComponentsBlocksFree1 dep
GitHub Pull Requestsgithub-prUI ComponentsBlocksFree1 dep
GitHub Starsgithub-starsUI ComponentsBlocksFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex