{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "border-beam",
  "title": "Border beam",
  "description": "Wraps any card or input and runs a light beam around its border, matching the element's corner radius automatically.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/cards/border-beam.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n// The ring is a padding-sized mask (content-box excluded); the beam travels the ring on an offset-path rect().\nconst CSS = `\n@keyframes pc-border-beam-move { from { offset-distance: 0% } to { offset-distance: 100% } }\n.pc-border-beam {\n  position: absolute; inset: 0; border-radius: var(--pc-bb-radius, 0px); padding: var(--pc-bb-width, 1px);\n  pointer-events: none; z-index: 1; overflow: hidden;\n  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor;\n  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);\n}\n.pc-border-beam-dot {\n  position: absolute; top: 0; left: 0; width: var(--pc-bb-size, 80px); aspect-ratio: 1;\n  offset-path: rect(0 auto auto 0 round var(--pc-bb-radius, 12px));\n  offset-anchor: 50% 50%;\n  background: linear-gradient(to left, var(--pc-bb-from), var(--pc-bb-to), transparent);\n  animation: pc-border-beam-move var(--pc-bb-duration, 6s) linear infinite;\n  animation-delay: var(--pc-bb-delay, 0s);\n}\n.pc-border-beam[data-reverse] .pc-border-beam-dot { animation-direction: reverse }\n.pc-border-beam[data-paused] .pc-border-beam-dot { animation-play-state: paused }\n@supports not (offset-path: rect(0 auto auto 0)) { .pc-border-beam { display: none } }\n@media (prefers-reduced-motion: reduce) { .pc-border-beam { display: none } }\n`\n\nexport type BorderBeamProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** Length of the beam in px. */\n  size?: number\n  /** Seconds per lap. */\n  duration?: number\n  /** Seconds to offset the start (useful for several beams). */\n  delay?: number\n  /** Head color of the beam. Defaults to the theme's --chart-1. */\n  colorFrom?: string\n  /** Tail color of the beam. Defaults to the theme's --chart-4. */\n  colorTo?: string\n  /** Width of the lit ring in px; match the border of the wrapped element. */\n  borderWidth?: number\n  /** Corner radius of the path. Defaults to the wrapped element's own radius. */\n  radius?: number\n  /** Run the beam the other way around the border. */\n  reverse?: boolean\n  /** Number of beams, spaced evenly around the border. */\n  beams?: 1 | 2\n}\n\n/**\n * Wraps any card or input and runs a light beam around its border. Measures the child's corner radius, pauses\n * off-screen and is hidden for reduced motion or in browsers without offset-path rect().\n */\nexport function BorderBeam({\n  size = 80,\n  duration = 6,\n  delay = 0,\n  colorFrom = \"var(--chart-1)\",\n  colorTo = \"var(--chart-4)\",\n  borderWidth = 1,\n  radius,\n  reverse = false,\n  beams = 1,\n  className,\n  style,\n  children,\n  ...props\n}: BorderBeamProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const [paused, setPaused] = React.useState(false)\n  const [measured, setMeasured] = React.useState<string | null>(null)\n\n  React.useEffect(() => {\n    const el = ref.current\n    if (!el) return\n    if (radius === undefined) {\n      const child = el.firstElementChild as HTMLElement | null\n      const r = child ? getComputedStyle(child).borderTopLeftRadius : \"0px\"\n      setMeasured(r && r !== \"0px\" ? r : getComputedStyle(el).borderTopLeftRadius)\n    }\n    // Pause the beam while off-screen.\n    const io = new IntersectionObserver(([entry]) => {\n      if (!entry) return\n      setPaused(!entry.isIntersecting)\n    })\n    io.observe(el)\n    return () => io.disconnect()\n  }, [radius])\n\n  const r = radius !== undefined ? `${radius}px` : measured ?? undefined\n\n  return (\n    <div\n      ref={ref}\n      className={cn(\"relative\", className)}\n      style={{\n        ...style,\n        [\"--pc-bb-size\" as string]: `${size}px`,\n        [\"--pc-bb-duration\" as string]: `${duration}s`,\n        [\"--pc-bb-from\" as string]: colorFrom,\n        [\"--pc-bb-to\" as string]: colorTo,\n        [\"--pc-bb-width\" as string]: `${borderWidth}px`,\n        ...(r ? { [\"--pc-bb-radius\" as string]: r } : {}),\n      }}\n      {...props}\n    >\n      <style href=\"pc-border-beam\" precedence=\"default\">\n        {CSS}\n      </style>\n      {children}\n      {r && (\n        <div aria-hidden=\"true\" className=\"pc-border-beam\" data-reverse={reverse ? \"\" : undefined} data-paused={paused ? \"\" : undefined}>\n          {Array.from({ length: beams }, (_, i) => (\n            <div key={i} className=\"pc-border-beam-dot\" style={{ [\"--pc-bb-delay\" as string]: `${-delay - (i * duration) / beams}s` }} />\n          ))}\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/border-beam.tsx"
    }
  ],
  "categories": [
    "components",
    "cards"
  ],
  "type": "registry:component"
}