{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggles-liquid",
  "title": "Liquid toggles",
  "description": "Styled toggles: the Liquid set. 5 decorative toggles variations (LiquidToggle, BlobToggle, DropToggle, WaveToggle, MercuryToggle) 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"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/toggles-liquid.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Liquid toggle family: 5 liquid switches. role=\"switch\", keyboard accessible. Color\n   comes ONLY from tokens. The thumb slides with the framer-motion `layout` and\n   switches instantly under reduced-motion; the morph/flow stops under\n   reduced-motion. Uncontrolled/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/* Liquid: dolgu toggle sirasinda sivi gibi akar. */\nexport function LiquidToggle(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], \"overflow-hidden rounded-full bg-input\", on ? \"justify-end\" : \"justify-start\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-full bg-primary\"\n        initial={false}\n        animate={{ clipPath: on ? \"circle(140% at 100% 50%)\" : \"circle(0% at 100% 50%)\" }}\n        transition={spring}\n      />\n      <motion.span layout transition={spring} className={cn(thumbSize[size], \"relative z-10 rounded-full bg-background shadow-sm\")} />\n    </button>\n  )\n}\n\n/* Blob: morph eden blob basparmak. */\nexport function BlobToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\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        className={cn(thumbSize[size], \"bg-background shadow-sm\")}\n        animate={\n          reduce\n            ? { borderRadius: \"50%\" }\n            : { borderRadius: on ? [\"50%\", \"60% 40% 55% 45%\", \"50%\"] : [\"50%\", \"45% 55% 40% 60%\", \"50%\"] }\n        }\n        transition={{ layout: spring, borderRadius: reduce ? { duration: 0 } : { duration: 0.7, ease: \"easeInOut\" } }}\n        style={{ borderRadius: \"50%\" }}\n      />\n    </button>\n  )\n}\n\n/* Drop: damla seklinde basparmak. */\nexport function DropToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\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        animate={reduce ? { rotate: 0 } : { rotate: on ? 135 : -45 }}\n        className={cn(thumbSize[size], \"bg-background shadow-sm\")}\n        style={{ borderRadius: \"50% 50% 50% 0\" }}\n      />\n    </button>\n  )\n}\n\n/* Wave: acikken izi bir dalga doldurur. */\nexport function WaveToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\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], \"overflow-hidden rounded-full bg-input\", on ? \"justify-end\" : \"justify-start\", props.className)}\n      {...stripToggleProps(props)}\n    >\n      <motion.span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-y-0 left-0 bg-info\"\n        initial={false}\n        animate={{ width: on ? \"100%\" : \"0%\" }}\n        transition={spring}\n      >\n        <motion.span\n          className=\"absolute top-0 right-0 h-full w-2 translate-x-1/2 rounded-full bg-info\"\n          animate={reduce || !on ? { y: 0 } : { y: [\"-12%\", \"12%\", \"-12%\"] }}\n          transition={reduce || !on ? { duration: 0 } : { duration: 1.2, repeat: Infinity, ease: \"easeInOut\" }}\n        />\n      </motion.span>\n      <motion.span layout transition={spring} className={cn(thumbSize[size], \"relative z-10 rounded-full bg-background shadow-sm\")} />\n    </button>\n  )\n}\n\n/* Mercury: metalik sivi basparmak, kayarken uzar. */\nexport function MercuryToggle(props: ToggleProps) {\n  const { on, toggle, spring } = useToggle(props)\n  const reduce = useReducedMotion()\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\n        layout\n        transition={spring}\n        animate={reduce ? { scaleX: 1 } : { scaleX: [1, 1.5, 1] }}\n        className={cn(thumbSize[size], \"rounded-full\")}\n        style={{\n          background: \"linear-gradient(160deg, color-mix(in oklab, var(--background) 92%, transparent), color-mix(in oklab, var(--foreground) 22%, transparent))\",\n          boxShadow: \"inset 0 1px 1px 0 color-mix(in oklab, var(--background) 90%, transparent), 0 1px 2px 0 color-mix(in oklab, var(--foreground) 30%, transparent)\",\n        }}\n      />\n    </button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/toggles-liquid.tsx"
    }
  ],
  "categories": [
    "styled",
    "toggles"
  ],
  "type": "registry:component"
}