{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"reveal-text","type":"registry:ui","title":"Reveal Text","description":"Letters rise out of a mask as they scroll into view; hover and a photo shows through the type.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/reveal-text.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type CSSProperties } from \"react\";\n\nconst css = `\n.reveal-text{position:relative;display:inline-block;cursor:default;white-space:nowrap}\n.reveal-text .rt-m{display:inline-block;overflow:hidden;vertical-align:top;padding-bottom:.08em;margin-bottom:-.08em}\n.reveal-text .rt-i{display:inline-block;transform:translateY(110%);transition:transform var(--rt-d) cubic-bezier(.2,.8,.2,1) calc(var(--i)*var(--rt-s))}\n.reveal-text[data-shown] .rt-i{transform:none}\n.reveal-text .rt-base{transition:opacity .5s ease}\n.reveal-text .rt-img{position:absolute;inset:0;color:transparent;-webkit-background-clip:text;background-clip:text;background-size:115% auto;background-position:50% 50%;opacity:0;transition:opacity .5s ease,background-size 1.2s cubic-bezier(.2,.8,.2,1)}\n.reveal-text[data-shown]:hover .rt-img{opacity:1;background-size:100% auto}\n.reveal-text[data-shown]:hover .rt-base{opacity:0}\n@media (prefers-reduced-motion:reduce){.reveal-text .rt-i{transition:none}}\n`;\n\nexport interface RevealTextProps {\n  text: string;\n  /** Image shown through the letters on hover. */\n  image: string;\n  /** Delay between letters, in ms. */\n  stagger?: number;\n  /** Slide duration of each letter, in ms. */\n  duration?: number;\n  className?: string;\n}\n\nexport function RevealText({ text, image, stagger = 45, duration = 900, className }: RevealTextProps) {\n  const ref = useRef<HTMLSpanElement>(null);\n  const [shown, setShown] = useState(false);\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([e]) => {\n      if (e.isIntersecting) {\n        setShown(true);\n        io.disconnect();\n      }\n    }, { threshold: 0.3 });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  const chars = Array.from(text);\n  const letters = (masked: boolean) =>\n    chars.map((c, i) => (\n      <span key={i} className={masked ? \"rt-m\" : undefined} style={masked ? undefined : { display: \"inline-block\" }}>\n        <span className={masked ? \"rt-i\" : undefined} style={{ display: \"inline-block\", whiteSpace: \"pre\", \"--i\": i } as CSSProperties}>\n          {c}\n        </span>\n      </span>\n    ));\n\n  return (\n    <span\n      ref={ref}\n      className={`reveal-text ${className ?? \"\"}`}\n      data-shown={shown || undefined}\n      style={{ \"--rt-s\": `${stagger}ms`, \"--rt-d\": `${duration}ms` } as CSSProperties}\n    >\n      <style href=\"reveal-text\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"sr-only\">{text}</span>\n      <span aria-hidden className=\"rt-base\">\n        {letters(true)}\n      </span>\n      <span aria-hidden className=\"rt-img\" style={{ backgroundImage: `url(\"${image}\")` }}>\n        {letters(false)}\n      </span>\n    </span>\n  );\n}\n"}]}