BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/Pure UI/switch

Switch

pure-ui/switch
FreeComponent

A customizable switch component

Install it

npx shadcn@latest add https://raw.githubusercontent.com/MusKRI/pure-ui/main/public/r/switch.json

Source

src/registry/pure-ui/ui/switch/index.tsxraw.githubusercontent.com/MusKRI/pure-ui/main/public/r/switch.json
1"use client";
2
3import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
4
5import { cn } from "@/lib/classes";
6
7interface SwitchProps extends SwitchPrimitive.Root.Props {
8 reduceMotion?: boolean;
9 isInteractive?: boolean;
10 size?: "sm" | "md" | "lg";
11}
12
13function Switch({
14 reduceMotion = false,
15 isInteractive = false,
16 size = "md",
17 className,
18 ...props
19}: SwitchProps) {
20 return (
21 <SwitchPrimitive.Root
22 {...props}
23 data-slot="switch"
24 className={cn(
25 "group relative rounded-full inline-flex items-center justify-start cursor-pointer touch-none select-none data-disabled:cursor-not-allowed data-disabled:opacity-70 px-1 bg-input inset-shadow-[0_1px_--theme(--color-black/4%)] data-checked:bg-primary",
26 size === "sm" && "w-10 h-6",
27 size === "md" && "w-12 h-7",
28 size === "lg" && "w-14 h-8",
29 !reduceMotion &&
30 "[transition-property:background-color] ease-[cubic-bezier(.25,.46,.45,.94)] duration-250",
31 className
32 )}
33 >
34 <SwitchPrimitive.Thumb
35 data-slot="switch-thumb"
36 className={cn(
37 "z-2 bg-white shadow-sm rounded-full origin-right pointer-events-none data-checked:bg-primary-foreground shrink-0",
38 size === "sm" && [
39 "size-4 text-xs data-checked:ms-4",
40 isInteractive && "group-active:w-5 data-checked:group-active:ml-3",
41 ],
42 size === "md" && [
43 "size-5 text-sm data-checked:ms-5",
44 isInteractive && "group-active:w-6 data-checked:group-active:ml-4",
45 ],
46 size === "lg" && [
47 "size-6 text-base data-checked:ms-6",
48 isInteractive && "group-active:w-7 data-checked:group-active:ml-5",
49 ],
50 !reduceMotion &&
51 "[transition-property:margin,transform,width,background-color] ease-[cubic-bezier(.25,.46,.45,.94)] duration-200"
52 )}
53 />
54 </SwitchPrimitive.Root>
55 );
56}
57
58export { Switch };

What it pulls in

npm packages

  • clsx
  • tailwind-merge
  • @base-ui/react

Other registry items

  • classes

Files it writes

  • src/registry/pure-ui/ui/switch/index.tsx

Facts

Registry
Pure UI
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
today

Go to the source

pure.kam-ui.com MusKRI/pure-ui on GitHub Raw registry item This item as JSON

More from Pure UI

All 291 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionPure UIComponentsFree4 deps
AvataravatarPure UIComponentsFree3 deps
BadgebadgePure UIComponentsFree4 deps
ButtonbuttonPure UIComponentsFree4 deps
Button Groupbutton-groupPure UIComponentsFree4 deps
CalendarcalendarPure UIComponentsFree4 deps
CardcardPure UIComponentsFree2 deps
CheckboxcheckboxPure UIComponentsFree4 deps
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