switch
formscn/switchFreeComponent
Switch component
Install it
npx shadcn@latest add https://formscn.space/r/switch.jsonSource
1import { Switch as SwitchPrimitive } from "@base-ui/react/switch"23import { cn } from "@/lib/utils"45function Switch({ className, ...props }: SwitchPrimitive.Root.Props) {6 return (7 <SwitchPrimitive.Root8 data-slot="switch"9 className={cn(10 "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-checked:bg-primary bg-input",11 className12 )}13 {...props}14 >15 <SwitchPrimitive.Thumb16 data-slot="switch-thumb"17 className={cn(18 "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-checked:translate-x-5 translate-x-0"19 )}20 />21 </SwitchPrimitive.Root>22 )23}2425export { Switch }
What it pulls in
npm packages
Files it writes
More from formscn
All 30 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| buttonbutton | formscn | Components | Free | 2 deps | |
| calendarcalendar | formscn | Components | Free | 2 deps | |
| cardcard | formscn | Components | Free | no deps | |
| checkboxcheckbox | formscn | Components | Free | 1 dep | |
| fieldfield | formscn | Components | Free | no deps | |
| inputinput | formscn | Components | Free | 1 dep | |
| labellabel | formscn | Components | Free | 2 deps | |
| phone-inputphone-input | formscn | Components | Free | 2 deps |
