{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"layered-text","type":"registry:ui","title":"Layered Text","description":"Colored copies hide behind each letter and fan out in a springy cascade on hover, then stack back.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/layered-text.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { Fragment, type CSSProperties } from \"react\";\n\nconst css = `\n.layered-text{display:inline-block;cursor:default;isolation:isolate}\n.layered-text .lt-c{position:relative;display:inline-block}\n.layered-text .lt-l{position:absolute;inset:0;pointer-events:none;transform:translate(0,0);transition:transform var(--lt-d) cubic-bezier(.34,1.56,.64,1) calc(var(--i)*var(--lt-s) + var(--j)*40ms)}\n.layered-text .lt-top{position:relative;z-index:1}\n.layered-text:hover .lt-l,.layered-text[data-active] .lt-l{transform:translate(calc(var(--lt-x)*var(--k)),calc(var(--lt-y)*var(--k)))}\n@media (prefers-reduced-motion:reduce){.layered-text .lt-l{transition:none}}\n`;\n\nexport interface LayeredTextProps {\n  text: string;\n  /** One color per layer, nearest first. */\n  colors?: string[];\n  /** Distance between layers when fanned out, in px. */\n  offset?: number;\n  /** Fan-out direction in degrees (0 = right, 90 = down). */\n  angle?: number;\n  /** Delay between letters, in ms. */\n  stagger?: number;\n  /** Transition duration, in ms. */\n  duration?: number;\n  /** Keep the layers fanned out. */\n  active?: boolean;\n  className?: string;\n}\n\nexport function LayeredText({\n  text,\n  colors = [\"#a3e635\", \"#22d3ee\", \"#818cf8\", \"#f472b6\"],\n  offset = 6,\n  angle = 45,\n  stagger = 30,\n  duration = 700,\n  active = false,\n  className,\n}: LayeredTextProps) {\n  const rad = (angle * Math.PI) / 180;\n  const words = text.split(\" \");\n  let i = 0;\n\n  return (\n    <span\n      className={`layered-text ${className ?? \"\"}`}\n      data-active={active || undefined}\n      style={\n        {\n          \"--lt-x\": `${(Math.cos(rad) * offset).toFixed(2)}px`,\n          \"--lt-y\": `${(Math.sin(rad) * offset).toFixed(2)}px`,\n          \"--lt-s\": `${stagger}ms`,\n          \"--lt-d\": `${duration}ms`,\n        } as CSSProperties\n      }\n    >\n      <style href=\"layered-text\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"sr-only\">{text}</span>\n      {words.map((word, w) => (\n        <Fragment key={w}>\n          <span aria-hidden style={{ display: \"inline-block\", whiteSpace: \"nowrap\" }}>\n            {Array.from(word).map((c, k) => {\n              const idx = i++;\n              return (\n                <span key={k} className=\"lt-c\" style={{ \"--i\": idx } as CSSProperties}>\n                  {colors\n                    .map((color, j) => (\n                      <span key={j} className=\"lt-l\" style={{ color, \"--j\": j, \"--k\": j + 1 } as CSSProperties}>\n                        {c}\n                      </span>\n                    ))\n                    .reverse()}\n                  <span className=\"lt-top\">{c}</span>\n                </span>\n              );\n            })}\n          </span>\n          {w < words.length - 1 && \" \"}\n        </Fragment>\n      ))}\n    </span>\n  );\n}\n"}]}