Switch
figui/switchFreeComponent
A switch component
Live preview
live · rendered by the registry
Rendered by figui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://figui.dev/r/switch.jsonSource
1import { cn } from "@/lib/utils";2import { Switch as BaseSwitch } from "@base-ui/react";34export function Switch({ className, ...props }: BaseSwitch.Root.Props) {5 return (6 <BaseSwitch.Root7 {...props}8 className={cn(9 "relative inline-flex h-4 w-8 shrink-0 items-center rounded-full p-[1px] transition-colors duration-200 ease-in-out outline-none focus-visible:ring focus-visible:inset-ring-2 focus-visible:ring-blue-500 focus-visible:inset-ring-white-1000 data-checked:bg-blue-500 data-disabled:bg-grey-300 data-unchecked:bg-grey-200 dark:focus-visible:ring-blue-400 dark:data-disabled:bg-grey-500 dark:data-unchecked:bg-grey-600",10 className,11 )}12 >13 <BaseSwitch.Thumb className="size-3.5 rounded-full bg-white-1000 transition-transform duration-150 data-checked:translate-x-4 data-disabled:bg-white-1000 dark:data-disabled:bg-grey-800" />14 </BaseSwitch.Root>15 );16}
Files it writes
More from figui
All 12 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Buttonbutton | figui | Components | Free | no deps | |
| Checkboxcheckbox | figui | Components | Free | no deps | |
| Inputinput | figui | Components | Free | 2 deps · 6 files | |
| Menumenu | figui | Components | Free | 1 dep | |
| Radioradio | figui | Components | Free | no deps | |
| Segmented Controlsegmented-control | figui | Components | Free | 1 dep | |
| Selectselect | figui | Components | Free | no deps | |
| Separatorseparator | figui | Components | Free | no deps |
