Switch
muffled-ui-registry/switchFreeComponent
Binary toggle on ink and paper. Hairline track, snap thumb motion, opacity hover and press.
Live preview
live · rendered by the registry
Rendered by muffled-ui-registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.muffled.studio/r/switch.jsonSource
1import { Switch as SwitchPrimitive } from "@base-ui/react/switch"23import { cn } from "@/registry/lib/surface"45function Switch({6 className,7 size = "default",8 ...props9}: SwitchPrimitive.Root.Props & {10 size?: "sm" | "default"11}) {12 return (13 <SwitchPrimitive.Root14 data-slot="switch"15 data-size={size}16 className={cn(17 "peer group/switch relative inline-flex shrink-0 items-center rounded-full border outline-none transition-opacity duration-[var(--d-drift)] ease-[var(--ease-drift)] hover:opacity-60 active:opacity-40 active:duration-[var(--d-snap)] active:ease-[var(--ease-snap)] after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:outline focus-visible:outline-offset-2 focus-visible:outline-ring data-disabled:cursor-not-allowed data-disabled:opacity-40 aria-invalid:border-destructive data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] data-checked:border-primary data-checked:bg-primary data-unchecked:border-border data-unchecked:bg-muted",18 className19 )}20 {...props}21 >22 <SwitchPrimitive.Thumb23 data-slot="switch-thumb"24 className="pointer-events-none block rounded-full bg-primary-foreground transition-transform duration-[var(--d-snap)] ease-[var(--ease-snap)] group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 data-unchecked:bg-foreground"25 />26 </SwitchPrimitive.Root>27 )28}2930export { Switch }
What it pulls in
npm packages
Other registry items
Files it writes
More from muffled-ui-registry
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | muffled-ui-registry | Components | Free | 2 deps | |
| Alertalert | muffled-ui-registry | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | muffled-ui-registry | Components | Free | 1 dep | |
| Avataravatar | muffled-ui-registry | Components | Free | 1 dep | |
| Badgebadge | muffled-ui-registry | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | muffled-ui-registry | Components | Free | 2 deps | |
| Buttonbutton | muffled-ui-registry | Components | Free | 2 deps | |
| Button Groupbutton-group | muffled-ui-registry | Components | Free | 2 deps |
