{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"outline-fill","type":"registry:ui","title":"Outline Fill","description":"Outlined lettering that draws its stroke, then wipes in a solid fill on view or on hover.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/outline-fill.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\n\nexport interface OutlineFillProps {\n  text: string;\n  strokeColor?: string;\n  fillColor?: string;\n  /** Outline thickness as a percentage of the font size. */\n  strokeWidth?: number;\n  /** Ms for the full draw + fill sequence. */\n  duration?: number;\n  /** Fill once scrolled into view, or only while hovered. */\n  trigger?: \"view\" | \"hover\";\n  className?: string;\n}\n\n// Glyphs are laid out at 100 user units so stroke width and dash length scale with the font.\nconst SIZE = 100;\nconst DASH = 900;\nconst css = `@media (prefers-reduced-motion: reduce){[data-stroke-text] *{transition:none!important}}`;\n\nexport function OutlineFill({\n  text,\n  strokeColor = \"#bef264\",\n  fillColor = \"#ecfccb\",\n  strokeWidth = 1.2,\n  duration = 2200,\n  trigger = \"view\",\n  className,\n}: OutlineFillProps) {\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const svg = useRef<SVGSVGElement>(null);\n  const measure = useRef<SVGTextElement>(null);\n  const [inView, setInView] = useState(false);\n  const [hovered, setHovered] = useState(false);\n\n  // Fit the viewBox to the rendered glyphs (again once web fonts load).\n  useEffect(() => {\n    const fit = () => {\n      const t = measure.current;\n      const s = svg.current;\n      if (!t || !s) return;\n      const b = t.getBBox();\n      const pad = SIZE * 0.06;\n      s.setAttribute(\"viewBox\", `${b.x - pad} ${b.y - pad} ${b.width + pad * 2} ${b.height + pad * 2}`);\n    };\n    fit();\n    document.fonts?.ready.then(fit);\n  }, [text]);\n\n  useEffect(() => {\n    const el = svg.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([entry]) => {\n      if (entry.isIntersecting) {\n        setInView(true);\n        io.disconnect();\n      }\n    });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  const filled = trigger === \"view\" ? inView : hovered;\n  const drawMs = duration * 0.65;\n  const fillMs = trigger === \"view\" ? duration * 0.5 : duration * 0.35;\n  const fillDelay = trigger === \"view\" ? duration * 0.45 : 0;\n  const ease = \"cubic-bezier(.65,0,.35,1)\";\n  const glyphs = { x: 0, y: 0, style: { font: \"inherit\", fontSize: SIZE, letterSpacing: \"inherit\" } };\n\n  return (\n    <span\n      className={className}\n      style={{ display: \"inline-block\", lineHeight: 1 }}\n      onPointerEnter={() => setHovered(true)}\n      onPointerLeave={() => setHovered(false)}\n    >\n      <style href=\"outline-fill\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"sr-only\">{text}</span>\n      <svg\n        ref={svg}\n        data-stroke-text=\"\"\n        aria-hidden\n        viewBox={`0 -${SIZE * 0.9} ${text.length * SIZE * 0.6} ${SIZE * 1.2}`}\n        style={{ display: \"block\", height: \"1.2em\", width: \"auto\", overflow: \"visible\" }}\n      >\n        <defs>\n          <linearGradient id={`${uid}-g`}>\n            <stop offset=\"0.5\" stopColor=\"#fff\" />\n            <stop offset=\"0.6\" stopColor=\"#000\" />\n          </linearGradient>\n          {/* Mask content is in bounding-box units: 1 = the text's width, so no measuring needed. */}\n          <mask id={`${uid}-m`} maskContentUnits=\"objectBoundingBox\">\n            <rect\n              x=\"-0.1\"\n              y=\"-0.5\"\n              width=\"2.4\"\n              height=\"2\"\n              fill={`url(#${uid}-g)`}\n              style={{\n                transform: filled ? \"translateX(0)\" : \"translateX(-1.45px)\",\n                transition: `transform ${fillMs}ms ${ease} ${filled ? fillDelay : 0}ms`,\n              }}\n            />\n          </mask>\n        </defs>\n        <text ref={measure} {...glyphs} fill={fillColor} mask={`url(#${uid}-m)`}>\n          {text}\n        </text>\n        <text\n          {...glyphs}\n          fill=\"none\"\n          stroke={strokeColor}\n          strokeWidth={strokeWidth}\n          strokeLinejoin=\"round\"\n          strokeDasharray={DASH}\n          style={{\n            ...glyphs.style,\n            strokeDashoffset: inView ? 0 : DASH,\n            transition: `stroke-dashoffset ${drawMs}ms ${ease}`,\n          }}\n        >\n          {text}\n        </text>\n      </svg>\n    </span>\n  );\n}\n"}]}