{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hover-string-underline",
  "type": "registry:component",
  "title": "String Underline",
  "description": "A link underline that behaves like a plucked string. It bends toward the pointer on a spring, follows it along the word and rings out when the pointer leaves. Wrap any text or link; reduced motion keeps a straight line.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hover",
    "underline",
    "link",
    "spring",
    "string",
    "pointer",
    "svg"
  ],
  "docs": "https://hyperblur.dev/effects/hover-string-underline",
  "files": [
    {
      "path": "registry/hyperblur/hover-string-underline.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/hover-string-underline.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface HoverStringUnderlineProps extends React.HTMLAttributes<HTMLSpanElement> {\n  children?: React.ReactNode;\n  color?: string;\n  thickness?: number;\n  strength?: number;\n  stiffness?: number;\n  damping?: number;\n}\n\nconst css = `\n.hb-hsu { position: relative; display: inline-block; padding-bottom: 2px; cursor: pointer; }\n.hb-hsu-svg { position: absolute; left: 0; right: 0; bottom: -11px; width: 100%; height: 24px; overflow: visible; pointer-events: none; }\n.hb-hsu-path { fill: none; stroke: var(--hb-hsu-c); stroke-width: var(--hb-hsu-t); stroke-linecap: round; vector-effect: non-scaling-stroke; }\n.hb-hsu::after { content: \"\"; position: absolute; left: -10px; right: -10px; top: -6px; bottom: -22px; }\n.hb-hsu:focus-visible { outline: 2px solid var(--hb-hsu-c); outline-offset: 6px; border-radius: 4px; }\n`;\n\nexport function HoverStringUnderline({\n  children = \"Hover the string\",\n  color = \"currentColor\",\n  thickness = 2,\n  strength = 1,\n  stiffness = 0.14,\n  damping = 0.9,\n  className = \"\",\n  style,\n  onPointerMove,\n  onPointerLeave,\n  ...rest\n}: HoverStringUnderlineProps) {\n  const root = React.useRef<HTMLSpanElement>(null);\n  const path = React.useRef<SVGPathElement>(null);\n  const state = React.useRef({ y: 0, v: 0, x: 50, tx: 50, ty: 0, raf: 0, last: 0 });\n\n  const draw = React.useCallback(() => {\n    const s = state.current;\n    path.current?.setAttribute(\"d\", `M0 12 Q${s.x.toFixed(2)} ${(12 + s.y * 2).toFixed(2)} 100 12`);\n  }, []);\n\n  const tick = React.useCallback(\n    (now: number) => {\n      const s = state.current;\n      const dt = Math.min(2, (now - (s.last || now)) / 16.67);\n      s.last = now;\n      s.v += (s.ty - s.y) * stiffness * dt;\n      s.v *= Math.pow(damping, dt);\n      s.y += s.v * dt;\n      s.x += (s.tx - s.x) * Math.min(1, 0.35 * dt);\n      draw();\n      if (Math.abs(s.v) > 0.01 || Math.abs(s.ty - s.y) > 0.01) {\n        s.raf = requestAnimationFrame(tick);\n      } else {\n        s.y = s.ty;\n        s.raf = 0;\n        s.last = 0;\n        draw();\n      }\n    },\n    [damping, draw, stiffness],\n  );\n\n  const wake = React.useCallback(() => {\n    const s = state.current;\n    if (!s.raf) s.raf = requestAnimationFrame(tick);\n  }, [tick]);\n\n  React.useEffect(() => {\n    const s = state.current;\n    draw();\n    return () => {\n      if (s.raf) cancelAnimationFrame(s.raf);\n    };\n  }, [draw]);\n\n  const move = (e: React.PointerEvent<HTMLSpanElement>) => {\n    onPointerMove?.(e);\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const el = root.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const s = state.current;\n    const dy = Math.max(-26, Math.min(26, e.clientY - (r.bottom - 2)));\n    s.tx = Math.max(4, Math.min(96, ((e.clientX - r.left) / Math.max(1, r.width)) * 100));\n    s.ty = dy * strength;\n    wake();\n  };\n\n  const leave = (e: React.PointerEvent<HTMLSpanElement>) => {\n    onPointerLeave?.(e);\n    const s = state.current;\n    s.tx = 50;\n    s.ty = 0;\n    wake();\n  };\n\n  const vars = { \"--hb-hsu-c\": color, \"--hb-hsu-t\": `${thickness}px`, ...style } as React.CSSProperties;\n\n  return (\n    <span\n      ref={root}\n      className={`hb-hsu ${className}`}\n      style={vars}\n      onPointerMove={move}\n      onPointerLeave={leave}\n      {...rest}\n    >\n      {children}\n      <svg className=\"hb-hsu-svg\" viewBox=\"0 0 100 24\" preserveAspectRatio=\"none\" aria-hidden=\"true\">\n        <path ref={path} className=\"hb-hsu-path\" d=\"M0 12 Q50 12 100 12\" />\n      </svg>\n      <style href=\"hb-hover-string-underline\" precedence=\"default\">{css}</style>\n    </span>\n  );\n}\n"
    }
  ]
}