{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggles-styled",
  "title": "Toggles essentials",
  "description": "Styled toggles: the essentials set. 5 decorative toggles variations (IOSToggle, SquareToggle, IconToggle, GlowToggle, LabeledToggle) on the ai2 token system, powered by framer-motion, reduced-motion aware and sized sm to xl. Part of the free styled layer.",
  "dependencies": [
    "motion@^12.42.2",
    "lucide-react@^1.23.0"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/toggles-styled.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Check, Moon, Sun, X } from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Toggle family: 5 decorative switches. role=\"switch\", keyboard accessible. Color\n   comes ONLY from tokens. Size = the track scale. The thumb slides with the\n   framer-motion `layout`; it switches instantly under reduced-motion. Used\n   uncontrolled (defaultChecked) or controlled. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nconst trackSize: Record<StyledSize, string> = {\n  sm: \"h-5 w-9 p-0.5\",\n  md: \"h-6 w-11 p-0.5\",\n  lg: \"h-7 w-[52px] p-1\",\n  xl: \"h-8 w-[60px] p-1\",\n}\nconst thumbSize: Record<StyledSize, string> = {\n  sm: \"size-4\",\n  md: \"size-5\",\n  lg: \"size-5\",\n  xl: \"size-6\",\n}\n\nconst trackBase =\n  \"relative inline-flex shrink-0 cursor-pointer items-center outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50\"\n\ninterface ToggleProps extends Omit<React.ComponentProps<\"button\">, \"onChange\"> {\n  size?: StyledSize\n  checked?: boolean\n  defaultChecked?: boolean\n  onCheckedChange?: (checked: boolean) => void\n}\n\nfunction useToggle(props: ToggleProps) {\n  const { checked, defaultChecked, onCheckedChange } = props\n  const reduce = useReducedMotion()\n  const [internal, setInternal] = React.useState(defaultChecked ?? false)\n  const on = checked ?? internal\n  const toggle = () => {\n    if (checked === undefined) setInternal((v) => !v)\n    onCheckedChange?.(!on)\n  }\n  const spring = reduce ? { duration: 0 } : ({ type: \"spring\", stiffness: 500, damping: 30 } as const)\n  return { on, toggle, spring }\n}\n\nfunction stripToggleProps(props: ToggleProps) {\n  const { checked, defaultChecked, onCheckedChange, size, className, children, ...rest } = props\n  return rest\n}\n\n/* iOS: klasik pill + yuvarlak basparmak. */\nexport function IOSToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-primary\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span layout transition={spring} className={cn(thumbSize[size], \"rounded-full bg-background shadow-sm\")} />\n    </button>\n  )\n}\n\n/* Square: koseli iz + kare basparmak. */\nexport function SquareToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-md transition-colors\", on ? \"justify-end bg-primary\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span layout transition={spring} className={cn(thumbSize[size], \"rounded-[3px] bg-background shadow-sm\")} />\n    </button>\n  )\n}\n\n/* Icon: basparmakta gunes/ay ikonu (tema anahtari hissi). */\nexport function IconToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-info\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        className={cn(thumbSize[size], \"flex items-center justify-center rounded-full bg-background text-foreground [&_svg]:size-2/3\")}\n      >\n        {on ? <Moon /> : <Sun />}\n      </motion.span>\n    </button>\n  )\n}\n\n/* Glow: acikken basparmak token isima yayar. */\nexport function GlowToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"md\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(trackBase, trackSize[size], \"rounded-full transition-colors\", on ? \"justify-end bg-success\" : \"justify-start bg-input\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        layout\n        transition={spring}\n        className={cn(thumbSize[size], \"rounded-full bg-background\", on && \"shadow-[0_0_10px_1px_var(--success)]\")}\n      />\n    </button>\n  )\n}\n\n/* Labeled: iz icinde ON/OFF + isaret ikonu. */\nexport function LabeledToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const size = props.size ?? \"lg\"\n  return (\n    <button\n      type=\"button\"\n      role=\"switch\"\n      aria-checked={on}\n      data-slot=\"styled-toggle\"\n      onClick={toggle}\n      className={cn(\n        trackBase,\n        \"h-7 w-16 p-1 text-[10px] font-semibold lg:text-xs\",\n        \"rounded-full transition-colors\",\n        on ? \"justify-end bg-primary text-primary-foreground\" : \"justify-start bg-input text-muted-foreground\",\n        props.className\n      )}\n      {...stripToggleProps(props)}\n    >\n      {on && <span className=\"absolute left-2 tracking-wide\">ON</span>}\n      {!on && <span className=\"absolute right-2 tracking-wide\">OFF</span>}\n      <motion.span\n        layout\n        transition={spring}\n        className=\"relative flex size-5 items-center justify-center rounded-full bg-background text-foreground [&_svg]:size-3\"\n      >\n        {on ? <Check /> : <X />}\n      </motion.span>\n    </button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/toggles-styled.tsx"
    }
  ],
  "categories": [
    "styled",
    "toggles"
  ],
  "type": "registry:component"
}