{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch",
  "title": "Switch",
  "description": "The thumb stretches toward the side it is moving to, then settles.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.2",
    "@ui-sdk/react@0.1.0-beta.2"
  ],
  "registryDependencies": [
    "@keyframery/motion"
  ],
  "files": [
    {
      "path": "registry/components/keyframery/primitives/switch.tsx",
      "content": "\"use client\"\n\n/* Animated drop-in for `@ui-sdk/react/switch`: same parts, same props. Swap the import and keep your code.\n   This file adds motion only. Colours, radii, shadows and spacing stay yours. */\n\nimport { Switch as SwitchPart, SwitchThumb as SwitchThumbPart } from \"@ui-sdk/react/switch\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport * from \"@ui-sdk/react/switch\"\n\n/* UI SDK accepts a class name or a function of state; keep both working. */\nfunction withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {\n  return typeof className === \"function\" ? (state: S) => cn(base, className(state)) : cn(base, className)\n}\n\n/* The track is the thumb's positioning box. Size the thumb with two variables:\n   `--kf-switch-thumb` (its resting width, 16px by default) and `--kf-switch-pad` (the gap\n   to the track's edge, 2px). The thumb fills the track's height minus the pad. */\nfunction Switch({ className, ...props }: React.ComponentProps<typeof SwitchPart>) {\n  return (\n    <SwitchPart\n      className={withClass(\"group/kf-switch relative [--kf-switch-pad:2px] [--kf-switch-thumb:16px]\", className)}\n      {...props}\n    />\n  )\n}\n\n/* Stretch: the thumb's two edges move separately. The edge facing the other side leaves at\n   once and the far edge follows 80ms later, so the thumb stretches toward where it is going\n   and closes up there. While the switch is held, the thumb widens by 4px toward the middle. */\nfunction SwitchThumb({ className, ...props }: React.ComponentProps<typeof SwitchThumbPart>) {\n  return (\n    <SwitchThumbPart\n      className={withClass(\n        cn(\n          \"absolute top-(--kf-switch-pad) bottom-(--kf-switch-pad) w-auto\",\n          /* Off: hugs the start. On: hugs the end. */\n          \"left-(--kf-switch-pad) right-[calc(100%-var(--kf-switch-pad)-var(--kf-switch-thumb))]\",\n          \"data-checked:right-(--kf-switch-pad) data-checked:left-[calc(100%-var(--kf-switch-pad)-var(--kf-switch-thumb))]\",\n          /* Held: 4px wider toward the middle. */\n          \"group-not-data-disabled/kf-switch:group-not-data-readonly/kf-switch:group-active/kf-switch:right-[calc(100%-var(--kf-switch-pad)-var(--kf-switch-thumb)-4px)]\",\n          \"group-not-data-disabled/kf-switch:group-not-data-readonly/kf-switch:group-active/kf-switch:data-checked:right-(--kf-switch-pad)\",\n          \"group-not-data-disabled/kf-switch:group-not-data-readonly/kf-switch:group-active/kf-switch:data-checked:left-[calc(100%-var(--kf-switch-pad)-var(--kf-switch-thumb)-4px)]\",\n          /* The leading edge goes first, the trailing edge 80ms later. */\n          \"data-checked:[transition:right_calc(260ms*var(--kf-speed,1))_var(--ease-spring),left_calc(420ms*var(--kf-speed,1))_var(--ease-spring)_calc(80ms*var(--kf-speed,1)),background-color_calc(200ms*var(--kf-speed,1)),box-shadow_calc(200ms*var(--kf-speed,1))]\",\n          \"data-unchecked:[transition:left_calc(260ms*var(--kf-speed,1))_var(--ease-spring),right_calc(420ms*var(--kf-speed,1))_var(--ease-spring)_calc(80ms*var(--kf-speed,1)),background-color_calc(200ms*var(--kf-speed,1)),box-shadow_calc(200ms*var(--kf-speed,1))]\",\n          \"group-active/kf-switch:[transition:left_calc(200ms*var(--kf-speed,1))_var(--ease-pop),right_calc(200ms*var(--kf-speed,1))_var(--ease-pop),background-color_calc(200ms*var(--kf-speed,1)),box-shadow_calc(200ms*var(--kf-speed,1))]!\",\n          \"motion-reduce:[transition:none]!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Switch, SwitchThumb }\n",
      "type": "registry:component",
      "target": "components/keyframery/primitives/switch.tsx"
    },
    {
      "path": "registry/components/keyframery/switch.tsx",
      "content": "\"use client\"\n\n/* Styled switch: the animated primitive plus the Keyframery look. */\n\nimport * as React from \"react\"\n\nimport { Switch as SwitchPrimitive, SwitchThumb as SwitchThumbPrimitive } from \"@/components/keyframery/primitives/switch\"\nimport { cn } from \"@/lib/utils\"\n\n/* Track: 38 x 22 with 2px of room around an 18px thumb. */\nfunction Switch({\n  className,\n  children,\n  ...props\n}: React.ComponentProps<typeof SwitchPrimitive>) {\n  return (\n    <SwitchPrimitive\n      className={cn(\n        \"inline-flex h-[22px] w-[38px] shrink-0 cursor-pointer rounded-full outline-none select-none [--kf-switch-thumb:18px]\",\n        /* Off: a pill well. */\n        \"bg-muted shadow-[inset_0_1px_2px_rgb(0_0_0/0.09),inset_0_0_0_1px_rgb(0_0_0/0.05)]\",\n        \"dark:bg-accent dark:shadow-[inset_0_1px_2px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(255_255_255/0.05)]\",\n        \"not-data-disabled:not-data-readonly:hover:bg-[color-mix(in_oklab,var(--muted),var(--foreground)_5%)]\",\n        \"dark:not-data-disabled:not-data-readonly:hover:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_6%)]\",\n        /* On: the well fills with primary. */\n        \"data-checked:bg-primary data-checked:shadow-[inset_0_1px_2px_rgb(0_0_0/0.2),inset_0_0_0_1px_rgb(0_0_0/0.05)]\",\n        \"dark:data-checked:bg-primary dark:data-checked:shadow-[inset_0_1px_2px_rgb(0_0_0/0.25)]\",\n        \"not-data-disabled:not-data-readonly:data-checked:hover:bg-[color-mix(in_oklab,var(--primary),var(--background)_10%)]\",\n        \"dark:not-data-disabled:not-data-readonly:data-checked:hover:bg-[color-mix(in_oklab,var(--primary),var(--background)_10%)]\",\n        \"data-invalid:shadow-[inset_0_1px_2px_rgb(0_0_0/0.09),inset_0_0_0_1px_var(--destructive)]\",\n        \"transition-[background-color,box-shadow] duration-[calc(200ms*var(--kf-speed,1))] ease-house motion-reduce:transition-none!\",\n        \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        \"data-disabled:cursor-not-allowed data-disabled:opacity-50 data-readonly:cursor-default\",\n        className as string,\n      )}\n      {...props}\n    >\n      {children ?? <SwitchThumb />}\n    </SwitchPrimitive>\n  )\n}\n\n/* Thumb: a round key. */\nfunction SwitchThumb({ className, ...props }: React.ComponentProps<typeof SwitchThumbPrimitive>) {\n  return (\n    <SwitchThumbPrimitive\n      className={cn(\n        \"pointer-events-none block rounded-full bg-background\",\n        \"shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_1px_rgb(0_0_0/0.06),0_2px_4px_-1px_rgb(0_0_0/0.16)]\",\n        \"dark:bg-[color-mix(in_oklab,var(--foreground),var(--background)_8%)] dark:shadow-[0_0_0_1px_rgb(0_0_0/0.25),0_1px_3px_rgb(0_0_0/0.5)]\",\n        \"dark:data-checked:bg-primary-foreground dark:data-checked:shadow-[inset_0_1px_0_rgb(255_255_255/0.08),0_1px_3px_rgb(0_0_0/0.45)]\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Switch, SwitchThumb }\n",
      "type": "registry:component",
      "target": "components/keyframery/switch.tsx"
    }
  ],
  "type": "registry:component"
}