{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch",
  "title": "Switch",
  "author": "Ballmac <https://ui.ballmac.com>",
  "description": "A Radix toggle switch in two sizes with a CSS-animated thumb, for settings that take effect immediately. Stops animating under reduced motion.",
  "dependencies": [
    "radix-ui",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/ballmac/components/switch.tsx",
      "content": "// Ballmac UI: Switch. https://ui.ballmac.com/components/switch\n// Based on shadcn/ui's Switch (MIT, Copyright (c) 2023 shadcn), restyled with sizes.\n\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Switch as SwitchPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst switchVariants = cva(\n  \"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs outline-none transition-[background-color,box-shadow] duration-200 motion-reduce:transition-none after:absolute after:-inset-2 after:content-[''] focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80\",\n  {\n    variants: {\n      size: {\n        sm: \"h-4 w-7\",\n        default: \"h-5 w-9\",\n      },\n    },\n    defaultVariants: { size: \"default\" },\n  }\n)\n\ntype SwitchProps = React.ComponentProps<typeof SwitchPrimitive.Root> & VariantProps<typeof switchVariants>\n\nfunction Switch({ className, size = \"default\", ...props }: SwitchProps) {\n  return (\n    <SwitchPrimitive.Root\n      data-slot=\"switch\"\n      data-size={size ?? \"default\"}\n      className={cn(switchVariants({ size }), className)}\n      {...props}\n    >\n      <SwitchPrimitive.Thumb\n        data-slot=\"switch-thumb\"\n        className={cn(\n          \"pointer-events-none block rounded-full bg-background shadow-[0_1px_2px_0_rgb(0_0_0/0.2)] ring-0 transition-transform duration-200 ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none data-[state=unchecked]:translate-x-px data-[state=checked]:translate-x-[calc(100%+1px)] rtl:data-[state=unchecked]:-translate-x-px rtl:data-[state=checked]:-translate-x-[calc(100%+1px)] dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground\",\n          \"size-4 group-data-[size=sm]/switch:size-3\"\n        )}\n      />\n    </SwitchPrimitive.Root>\n  )\n}\n\nexport { Switch, switchVariants, type SwitchProps }\n",
      "type": "registry:ui",
      "target": "@components/ballmac/switch.tsx"
    }
  ],
  "meta": {
    "schema": 1,
    "tier": "free",
    "tags": [
      "switch",
      "toggle",
      "settings",
      "form",
      "radix"
    ],
    "version": "1.0.0",
    "updated": "2026-09-28",
    "ai": {
      "summary": "On/off control for settings that apply immediately. Pair with a Label via id/htmlFor; use size=\"sm\" in dense lists.",
      "whenToUse": [
        "Enabling or disabling a feature or notification",
        "Settings pages with labelled rows",
        "Toggles inside dense menus or tables (size sm)"
      ],
      "whenNotToUse": [
        "Choices submitted later with a form, or agreeing to terms (use checkbox)",
        "More than two options (use select)"
      ],
      "composesWith": [
        "label",
        "badge"
      ],
      "a11y": [
        {
          "keys": "Space",
          "action": "Toggles the switch"
        },
        {
          "keys": "Enter",
          "action": "Toggles the switch"
        },
        {
          "keys": "Tab",
          "action": "Moves focus to the switch"
        }
      ],
      "customization": [
        "size: sm | default",
        "checked / defaultChecked with onCheckedChange",
        "aria-invalid=\"true\" for errors"
      ]
    },
    "source": {
      "name": "shadcn/ui Switch",
      "url": "https://github.com/shadcn-ui/ui",
      "license": "MIT",
      "copyright": "Copyright (c) 2023 shadcn",
      "modified": true
    },
    "examples": [
      "switch-demo",
      "switch-settings"
    ],
    "url": "https://ui.ballmac.com/components/switch"
  },
  "categories": [
    "primitives"
  ],
  "type": "registry:ui"
}