{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-stroke",
  "title": "Text Stroke / Outline Text",
  "description": "Big outlined lettering with fading echoes stacked beneath it, and a solid fill that follows the pointer through the word.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/text-stroke/text-stroke.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TextStrokeProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"children\"\n> {\n  text?: string;\n  /** Outline thickness, in px. */\n  strokeWidth?: number;\n  /** Outlined copies stacked beneath the word. */\n  echoes?: number;\n  /** Radius of the solid fill that follows the pointer, in px. Set 0 to turn it off. */\n  fillRadius?: number;\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nexport function TextStroke({\n  text = \"OUTLINE\",\n  strokeWidth = 1.5,\n  echoes = 3,\n  fillRadius = 130,\n  className,\n  style,\n  onPointerMove,\n  onPointerLeave,\n  ...props\n}: TextStrokeProps) {\n  const reduce = useReducedMotion();\n  const fillRef = React.useRef<HTMLSpanElement>(null);\n  const goal = React.useRef({ x: 0, y: 0, r: 0 });\n  const raf = React.useRef(0);\n  const start = React.useRef<() => void>(() => {});\n\n  // The fill eases after the pointer and shrinks away when it leaves.\n  React.useEffect(() => {\n    const el = fillRef.current;\n    if (!el) return;\n    const now = { x: 0, y: 0, r: 0 };\n    const frame = () => {\n      const g = goal.current;\n      const k = reduce ? 1 : 0.16;\n      now.x += (g.x - now.x) * k;\n      now.y += (g.y - now.y) * k;\n      now.r += (g.r - now.r) * k;\n      el.style.clipPath = `circle(${now.r.toFixed(1)}px at ${now.x.toFixed(1)}px ${now.y.toFixed(1)}px)`;\n      const moving =\n        Math.abs(g.x - now.x) + Math.abs(g.y - now.y) + Math.abs(g.r - now.r) >\n        0.4;\n      raf.current = moving ? requestAnimationFrame(frame) : 0;\n    };\n    start.current = () => {\n      if (!raf.current) raf.current = requestAnimationFrame(frame);\n    };\n    return () => {\n      cancelAnimationFrame(raf.current);\n      raf.current = 0;\n    };\n  }, [reduce]);\n\n  const outline: React.CSSProperties = {\n    color: \"transparent\",\n    WebkitTextStroke: `${strokeWidth}px currentColor`,\n  };\n\n  return (\n    <div\n      className={`relative inline-block leading-none ${className ?? \"\"}`}\n      style={style}\n      aria-label={text}\n      role=\"img\"\n      {...props}\n      onPointerMove={(e) => {\n        onPointerMove?.(e);\n        if (e.pointerType !== \"mouse\" || !fillRadius) return;\n        const r = e.currentTarget.getBoundingClientRect();\n        goal.current = {\n          x: e.clientX - r.left,\n          y: e.clientY - r.top,\n          r: fillRadius,\n        };\n        start.current();\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        goal.current = { ...goal.current, r: 0 };\n        start.current();\n      }}\n    >\n      {Array.from({ length: echoes }, (_, i) => (\n        <span\n          key={i}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 top-0 block select-none\"\n          style={{\n            WebkitTextStroke: `${strokeWidth}px currentColor`,\n            WebkitTextFillColor: \"transparent\",\n            transform: `translateY(${(i + 1) * 0.14}em)`,\n            opacity: 0.34 - i * (0.3 / Math.max(1, echoes)),\n          }}\n        >\n          {text}\n        </span>\n      ))}\n      <span aria-hidden=\"true\" className=\"relative block\" style={outline}>\n        <span style={{ color: \"transparent\" }}>{text}</span>\n      </span>\n      <span\n        ref={fillRef}\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 block\"\n        style={{ clipPath: \"circle(0px at 0px 0px)\" }}\n      >\n        {text}\n      </span>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}