{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch",
  "title": "Switch",
  "description": "Astro on/off controls for settings with data-slot state handling.",
  "dependencies": [
    "@data-slot/switch",
    "cn"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "packages/ui/src/components/ui/switch/index.ts",
      "content": "export { default as Switch } from './switch.astro'\nexport type { SwitchProps } from './types.ts'\n",
      "type": "registry:file",
      "target": "~/src/components/ui/switch/index.ts"
    },
    {
      "path": "packages/ui/src/components/ui/switch/switch.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"cn\"\nimport type { SwitchProps } from \"./types.ts\"\n\ntype Props = HTMLAttributes<\"span\"> & SwitchProps\n\nconst {\n  class: className,\n  defaultChecked,\n  disabled,\n  readOnly,\n  required,\n  name,\n  size = \"default\",\n  value,\n  uncheckedValue,\n  ...props\n} = Astro.props\n\nconst initialChecked = defaultChecked === true\nconst switchStyle = \"inline-flex h-[calc(var(--thumb-size)+2px)] w-[calc(var(--thumb-size)*2-2px)] shrink-0 items-center rounded-full p-px outline-none transition-[background-color,box-shadow] duration-200 [--thumb-size:--spacing(5)] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-disabled:cursor-not-allowed data-checked:bg-primary data-unchecked:bg-input data-disabled:opacity-64 sm:[--thumb-size:--spacing(4)] relative data-readonly:cursor-default aria-invalid:ring-destructive/24 peer group/switch\"\nconst switchSizeStyle = {\n  sm: \"[--thumb-size:--spacing(4)] sm:[--thumb-size:--spacing(3)]\",\n  default: \"\",\n}\n---\n\n<span\n  role=\"switch\"\n  aria-checked={initialChecked ? \"true\" : \"false\"}\n  aria-disabled={disabled ? \"true\" : undefined}\n  aria-readonly={readOnly ? \"true\" : undefined}\n  aria-required={required ? \"true\" : undefined}\n  data-slot=\"switch\"\n  data-size={size}\n  data-checked={initialChecked ? \"\" : undefined}\n  data-unchecked={initialChecked ? undefined : \"\"}\n  data-default-checked={defaultChecked}\n  data-disabled={disabled ? \"true\" : undefined}\n  data-read-only={readOnly}\n  data-readonly={readOnly ? \"\" : undefined}\n  data-required={required}\n  data-name={name}\n  data-value={value}\n  data-unchecked-value={uncheckedValue}\n  class={cn(switchStyle, switchSizeStyle[size], className)}\n  {...props}\n>\n  <span\n    aria-hidden=\"true\"\n    data-slot=\"switch-thumb\"\n    data-checked={initialChecked ? \"\" : undefined}\n    data-unchecked={initialChecked ? undefined : \"\"}\n    class=\"pointer-events-none block aspect-square h-full origin-left in-[[role=switch]:active,[data-slot=label]:active,[data-slot=field-label]:active]:not-data-disabled:scale-x-110 in-[[role=switch]:active,[data-slot=label]:active,[data-slot=field-label]:active]:rounded-[var(--thumb-size)/calc(var(--thumb-size)*1.1)] rounded-(--thumb-size) bg-background shadow-sm/5 will-change-transform [transition:translate_.15s,border-radius_.15s,scale_.1s_.1s,transform-origin_.15s] data-checked:origin-[var(--thumb-size)_50%] data-checked:translate-x-[calc(var(--thumb-size)-4px)]\"\n  ></span>\n</span>\n\n<script>\n  import { create } from \"@data-slot/switch\"\n  import type { SwitchController } from \"@data-slot/switch\"\n  // Destroy bindings before a view transition so the next page-load binds once.\n  const controllers: SwitchController[] = []\n  const initialize = () => controllers.push(...create())\n  initialize()\n  document.addEventListener(\"astro:page-load\", initialize)\n  document.addEventListener(\"astro:before-swap\", () => {\n    for (const controller of controllers) controller.destroy()\n    controllers.length = 0\n  })\n</script>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/switch/switch.astro"
    },
    {
      "path": "packages/ui/src/components/ui/switch/types.ts",
      "content": "import type { SwitchOptions } from '@data-slot/switch'\n\n/**\n * Switch configuration rendered as data attributes, plus the visual size.\n */\nexport type SwitchProps = Pick<\n    SwitchOptions,\n    | 'defaultChecked'\n    | 'disabled'\n    | 'readOnly'\n    | 'required'\n    | 'name'\n    | 'value'\n    | 'uncheckedValue'\n> & {\n    /**\n     * Height of the control.\n     *\n     * @default \"default\"\n     */\n    size?: 'default' | 'sm'\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/switch/types.ts"
    }
  ],
  "meta": {
    "framework": "astro",
    "source": "@gnostic/ui",
    "testedDependencies": {
      "@data-slot/switch": "^1.1.2",
      "cn": "0.5.2"
    }
  },
  "docs": "https://ui.gnosticai.com/components/switch",
  "categories": [
    "ui"
  ],
  "type": "registry:ui"
}
