8-bit Switch
8bitcn/switchFreeComponent
A simple 8-bit switch component
Install it
npx shadcn@latest add https://www.8bitcn.com/r/switch.jsonSource
1"use client";23import type * as React from "react";45import * as SwitchPrimitive from "@radix-ui/react-switch";67import { cn } from "@/lib/utils";89function Switch({10 className,11 ...props12}: React.ComponentProps<typeof SwitchPrimitive.Root>) {13 return (14 <SwitchPrimitive.Root15 data-slot="switch"16 className={cn(17 "relative peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-4 w-8 shrink-0 items-center border border-transparent shadow-xs transition-all outline-none border-none disabled:cursor-not-allowed disabled:opacity-50",18 className19 )}20 {...props}21 >22 <SwitchPrimitive.Thumb23 data-slot="switch-thumb"24 className={cn(25 "bg-primary data-[state=checked]:bg-primary-foreground dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 data-[state=checked]:border-l data-[state=unchecked]:border-r border-foreground dark:border-ring ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%)] data-[state=unchecked]:translate-x-0"26 )}27 />2829 <div30 className="absolute inset-0 border-y-4 -my-1 border-foreground dark:border-ring pointer-events-none"31 aria-hidden="true"32 />3334 <div35 className="absolute inset-0 border-x-4 -mx-1 border-foreground dark:border-ring pointer-events-none"36 aria-hidden="true"37 />38 </SwitchPrimitive.Root>39 );40}4142export { Switch };
What it pulls in
Other registry items
Files it writes
More from 8bitcn
All 121 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 8-bit Accordionaccordion | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Alertalert | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Alert Dialogalert-dialog | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Avataravatar | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Badgebadge | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Breadcrumbbreadcrumb | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Buttonbutton | 8bitcn | Components | Free | no deps · 2 files | |
| 8-bit Button Groupbutton-group | 8bitcn | Components | Free | no deps · 4 files |
