{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"fancy-text","type":"registry:ui","title":"Fancy Text","description":"Outlined letters that lift and fill with a sweeping gradient, one after another, on hover.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/fancy-text.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { Fragment, type CSSProperties } from \"react\";\n\nconst css = `\n.fancy-text{display:inline-block;cursor:default}\n.fancy-text .ft-l{position:relative;display:inline-block;transition:transform var(--ft-d) cubic-bezier(.3,1.5,.5,1) calc(var(--i)*var(--ft-s))}\n.fancy-text .ft-o{color:transparent;-webkit-text-stroke:var(--ft-w) var(--ft-stroke)}\n.fancy-text .ft-f{position:absolute;inset:0;color:transparent;background-image:var(--ft-g);background-size:var(--ft-n) 100%;background-position:var(--ft-p) 0;-webkit-background-clip:text;background-clip:text;clip-path:inset(-20% 100% -20% 0);transition:clip-path var(--ft-d) cubic-bezier(.6,0,.2,1) calc(var(--i)*var(--ft-s))}\n.fancy-text:hover .ft-l,.fancy-text:focus-visible .ft-l,.fancy-text[data-active] .ft-l{transform:translateY(calc(var(--ft-lift)*-1))}\n.fancy-text:hover .ft-f,.fancy-text:focus-visible .ft-f,.fancy-text[data-active] .ft-f{clip-path:inset(-20% -10% -20% 0)}\n@media (prefers-reduced-motion:reduce){.fancy-text .ft-l,.fancy-text .ft-f{transition-duration:0s;transition-delay:0s}}\n`;\n\nexport interface FancyTextProps {\n  text: string;\n  /** Gradient stops for the filled state. */\n  colors?: string[];\n  /** Outline color in the resting state. Defaults to a faint foreground. */\n  strokeColor?: string;\n  /** Outline width, in px. */\n  strokeWidth?: number;\n  /** How far each letter rises on hover, in em. */\n  lift?: number;\n  /** Delay between letters, in ms. */\n  stagger?: number;\n  /** Duration of each letter's sweep, in ms. */\n  duration?: number;\n  /** Keep the filled state on, e.g. to drive it from a parent. */\n  active?: boolean;\n  className?: string;\n}\n\nexport function FancyText({\n  text,\n  colors = [\"#a3e635\", \"#22d3ee\", \"#a78bfa\"],\n  strokeColor = \"color-mix(in oklab, var(--foreground, #fff) 55%, transparent)\",\n  strokeWidth = 1.5,\n  lift = 0.08,\n  stagger = 40,\n  duration = 600,\n  active = false,\n  className,\n}: FancyTextProps) {\n  const chars = Array.from(text);\n  const n = Math.max(chars.length, 1);\n  const words = text.split(\" \");\n  let i = 0;\n\n  return (\n    <span\n      className={`fancy-text ${className ?? \"\"}`}\n      data-active={active || undefined}\n      style={\n        {\n          \"--ft-g\": `linear-gradient(90deg, ${colors.join(\", \")})`,\n          \"--ft-n\": `${n * 100}%`,\n          \"--ft-stroke\": strokeColor,\n          \"--ft-w\": `${strokeWidth}px`,\n          \"--ft-lift\": `${lift}em`,\n          \"--ft-s\": `${stagger}ms`,\n          \"--ft-d\": `${duration}ms`,\n        } as CSSProperties\n      }\n    >\n      <style href=\"fancy-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              const style = { \"--i\": idx, \"--ft-p\": `${n > 1 ? (idx / (n - 1)) * 100 : 0}%` } as CSSProperties;\n              return (\n                <span key={k} className=\"ft-l\" style={style}>\n                  <span className=\"ft-o\">{c}</span>\n                  <span className=\"ft-f\">{c}</span>\n                </span>\n              );\n            })}\n          </span>\n          {w < words.length - 1 && (i++, \" \")}\n        </Fragment>\n      ))}\n    </span>\n  );\n}\n"}]}