{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shimmer-text",
  "title": "Shimmer Text",
  "description": "A band of light sweeping across text now and then, paused off screen.",
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/use-in-view"
  ],
  "files": [
    {
      "path": "registry/default/ui/shimmer-text.tsx",
      "content": "\"use client\";\n\nimport { useMemo, type ComponentProps, type CSSProperties, type Ref } from \"react\";\n\nimport { useInView } from \"@/registry/default/hooks/use-in-view\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\nfunction mergeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n  return (node: T | null) => {\n    for (const ref of refs) {\n      if (typeof ref === \"function\") ref(node);\n      else if (ref) ref.current = node;\n    }\n  };\n}\n\n// The band is 40% of the text wide, so a background position of -70% hides\n// it past the left edge and 170% past the right.\nconst BAND = \"40% 100%\";\nconst SWEEP_FROM = -70;\nconst SWEEP_LENGTH = 240;\n\ninterface ShimmerTextProps extends ComponentProps<\"span\"> {\n  /** Seconds the light takes to cross the text. */\n  duration?: number;\n  /** Seconds of rest between passes. */\n  pause?: number;\n  /** Seconds before the first pass. */\n  delay?: number;\n  /** Colour of the light. Defaults to the page colour mixed into the text colour. */\n  highlight?: string;\n}\n\n/**\n * A band of light that sweeps across text now and then, like sun on a\n * brass plate. The text keeps its own colour (set it with a `text-*` class);\n * the light is the page colour by default, so it reads in light and dark\n * themes alike. It is one CSS animation of the background, paused while off\n * screen, and plain text with `prefers-reduced-motion`.\n *\n * @example\n * <ShimmerText className=\"text-muted-foreground\">Charting a course…</ShimmerText>\n */\nfunction ShimmerText({\n  duration = 1.8,\n  pause = 2,\n  delay = 0.8,\n  highlight,\n  className,\n  style,\n  ref,\n  children,\n  ...props\n}: ShimmerTextProps) {\n  const [observe, inView] = useInView<HTMLSpanElement>({ rootMargin: \"100px\" });\n  const mergedRef = useMemo(() => mergeRefs(ref, observe), [ref, observe]);\n\n  // The rest between passes is the band travelling on past the end of the\n  // text, so one animation covers both and the timing stays in CSS.\n  const cycle = Math.max(duration, 0.01) + Math.max(pause, 0);\n  const end = SWEEP_FROM + SWEEP_LENGTH * (cycle / Math.max(duration, 0.01));\n\n  return (\n    <span\n      ref={mergedRef}\n      data-slot=\"shimmer-text\"\n      className={cn(\n        \"motion-safe:animate-shimmer-text inline-block bg-clip-text bg-no-repeat [-webkit-text-fill-color:transparent]\",\n        \"motion-reduce:[-webkit-text-fill-color:currentColor]\",\n        className\n      )}\n      style={\n        {\n          \"--shimmer-text-light\":\n            highlight ?? \"color-mix(in oklab, currentColor 25%, var(--background))\",\n          \"--shimmer-text-from\": `${SWEEP_FROM}%`,\n          \"--shimmer-text-to\": `${end}%`,\n          backgroundColor: \"currentColor\",\n          // A soft, slanted peak of light over the text colour.\n          backgroundImage:\n            \"linear-gradient(105deg, transparent 20%, var(--shimmer-text-light) 50%, transparent 80%)\",\n          backgroundSize: BAND,\n          backgroundPositionX: `${SWEEP_FROM}%`,\n          animationDuration: `${cycle}s`,\n          animationDelay: `${delay}s`,\n          animationPlayState: inView ? undefined : \"paused\",\n          ...style,\n        } as CSSProperties\n      }\n      {...props}\n    >\n      {children}\n    </span>\n  );\n}\n\nexport { ShimmerText, type ShimmerTextProps };\n",
      "type": "registry:ui"
    }
  ],
  "tailwind": {
    "config": {
      "theme": {
        "extend": {
          "keyframes": {
            "shimmer-text": {
              "from": {
                "background-position-x": "var(--shimmer-text-from)"
              },
              "to": {
                "background-position-x": "var(--shimmer-text-to)"
              }
            }
          },
          "animation": {
            "shimmer-text": "shimmer-text 3s linear infinite"
          }
        }
      }
    }
  },
  "cssVars": {
    "theme": {
      "animate-shimmer-text": "shimmer-text 3s linear infinite"
    }
  },
  "css": {
    "@keyframes shimmer-text": {
      "from": {
        "background-position-x": "var(--shimmer-text-from)"
      },
      "to": {
        "background-position-x": "var(--shimmer-text-to)"
      }
    }
  },
  "categories": [
    "text"
  ],
  "type": "registry:ui"
}