{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch",
  "title": "Switch",
  "author": "Tori Bryan",
  "description": "Turns a setting on or off, taking effect at once.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/ui/switch.tsx",
      "content": "\"use client\"\n\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\"\n\nimport { useFieldSize } from \"@/lib/field-size\"\nimport { cn } from \"@/lib/utils\"\n\nfunction Switch({\n  className,\n  size: sizeProp,\n  ...props\n}: SwitchPrimitive.Root.Props & {\n  /** The track's size: 32 by 18 pixels, or 24 by 14 for dense rows. */\n  size?: \"sm\" | \"default\"\n}) {\n  const size = useFieldSize(sizeProp)\n  return (\n    <SwitchPrimitive.Root\n      data-slot=\"switch\"\n      data-size={size}\n      className={cn(\n        \"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring-subtle aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive-ring data-[size=default]:h-[18px] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 motion-reduce:transition-none data-checked:bg-primary data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n        className\n      )}\n      {...props}\n    >\n      {/* The page color would vanish on a dark track, so in dark mode the\n          resting thumb takes the text color instead. */}\n      <SwitchPrimitive.Thumb\n        data-slot=\"switch-thumb\"\n        className=\"pointer-events-none block rounded-full shadow-sm ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 motion-reduce:transition-none data-checked:translate-x-[calc(100%-2px)] data-checked:bg-primary-foreground data-unchecked:translate-x-0 data-unchecked:bg-background dark:data-unchecked:bg-foreground\"\n      />\n    </SwitchPrimitive.Root>\n  )\n}\n\nexport { Switch }\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/lib/field-size.ts",
      "content": "import * as React from \"react\"\n\nexport type FieldSize = \"sm\" | \"default\"\n\n/**\n * The size a FieldGroup or Field sets for the controls inside it. It lives\n * here rather than in the Field part so a control can read it without\n * installing Field.\n */\nexport const FieldSizeContext = React.createContext<FieldSize | undefined>(\n  undefined\n)\n\n/** A control's own size wins, then the nearest Field's or FieldGroup's. */\nexport function useFieldSize(size?: FieldSize): FieldSize {\n  const inherited = React.useContext(FieldSizeContext)\n  return size ?? inherited ?? \"default\"\n}\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-destructive-ring": "var(--destructive-ring)",
      "color-ring-subtle": "var(--ring-subtle)",
      "border-color-destructive": "var(--destructive-border)"
    },
    "light": {
      "destructive-ring": "color-mix(in oklch, var(--color-red-700) 20%, transparent)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-400) 50%, transparent)",
      "destructive-border": "var(--destructive)"
    },
    "dark": {
      "destructive-ring": "color-mix(in oklch, var(--color-red-400) 40%, transparent)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-500) 50%, transparent)",
      "destructive-border": "var(--destructive)"
    }
  },
  "meta": {
    "tier": "base-components",
    "group": "Forms",
    "docs": "https://fibo.toribryan.com/?path=/docs/base-components-forms-switch--docs"
  },
  "docs": "Docs and live examples: https://fibo.toribryan.com/?path=/docs/base-components-forms-switch--docs",
  "categories": [
    "base-components",
    "forms"
  ],
  "type": "registry:ui"
}