{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "icon-swap",
  "title": "Icon swap",
  "description": "Cross-fades between two glyphs on an infrequent state change.",
  "dependencies": [
    "motion@^12.23.12"
  ],
  "files": [
    {
      "path": "registry/khaeli/ui/icon-swap.tsx",
      "content": "\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport { AnimatePresence, useReducedMotion } from \"motion/react\"\nimport * as m from \"motion/react-m\"\n\nconst SWAP = { type: \"spring\", duration: 0.3, bounce: 0 } as const\n\n/** Cross-fades between two glyphs on an infrequent state change\n *  (copy→copied, favourite). Keyed by `state`; the first render never animates. */\nexport function IconSwap({ state, children }: { state: string; children: ReactNode }) {\n  const reduce = useReducedMotion()\n  // Both branches set the same properties, so the style the server writes\n  // (it cannot read the motion setting) is the style the browser expects.\n  // Under reduced motion scale and blur hold still and only opacity moves.\n  const hidden = reduce\n    ? { opacity: 0, scale: 1, filter: \"blur(0px)\" }\n    : { opacity: 0, scale: 0.25, filter: \"blur(4px)\" }\n  const shown = { opacity: 1, scale: 1, filter: \"blur(0px)\" }\n  return (\n    <span className=\"relative inline-grid place-items-center\">\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        <m.span key={state} className=\"[grid-area:1/1] inline-flex\" initial={hidden} animate={shown} exit={hidden} transition={SWAP}>\n          {children}\n        </m.span>\n      </AnimatePresence>\n    </span>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.",
  "type": "registry:ui"
}