{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "animated-border",
  "title": "Animated Border",
  "description": "A border with a light travelling around it, paused off screen.",
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/use-in-view"
  ],
  "files": [
    {
      "path": "registry/default/ui/animated-border.tsx",
      "content": "\"use client\";\n\nimport { useMemo, type ComponentProps, 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\ninterface AnimatedBorderProps extends ComponentProps<\"div\"> {\n  /** Seconds for the light to go around once. */\n  duration?: number;\n  /** Colour of the light: any CSS colour, including theme variables. */\n  color?: string;\n  /** Border width, in px. */\n  width?: number;\n  /** Classes for the surface inside the border, where the content sits. */\n  contentClassName?: string;\n}\n\n/**\n * A border with a light travelling around it. The light is one rotating\n * layer (transform only, so the compositor does the work), it pauses while\n * off screen, and it holds still with `prefers-reduced-motion`. Set the\n * radius on the component; the surface inside follows it.\n *\n * The layer is sized from the width, which covers anything up to about\n * 1.7 times taller than it is wide.\n */\nfunction AnimatedBorder({\n  duration = 6,\n  color = \"var(--primary)\",\n  width = 1,\n  className,\n  contentClassName,\n  style,\n  children,\n  ref,\n  ...props\n}: AnimatedBorderProps) {\n  const [observe, inView] = useInView<HTMLDivElement>({ rootMargin: \"100px\" });\n  const mergedRef = useMemo(() => mergeRefs(ref, observe), [ref, observe]);\n\n  return (\n    <div\n      ref={mergedRef}\n      data-slot=\"animated-border\"\n      className={cn(\"bg-border relative isolate overflow-hidden rounded-xl\", className)}\n      style={{ padding: width, ...style }}\n      {...props}\n    >\n      {/* Centered with margins rather than a transform, which the spin would overwrite. */}\n      <span\n        aria-hidden=\"true\"\n        data-slot=\"animated-border-light\"\n        className=\"pointer-events-none absolute top-1/2 left-1/2 -mt-[100%] -ml-[100%] aspect-square w-[200%] animate-spin motion-reduce:animate-none\"\n        style={{\n          background: `conic-gradient(from 0deg, transparent 0 62%, ${color} 82%, transparent 96%)`,\n          animationDuration: `${duration}s`,\n          animationPlayState: inView ? \"running\" : \"paused\",\n        }}\n      />\n      <div\n        data-slot=\"animated-border-content\"\n        className={cn(\n          \"bg-card text-card-foreground relative h-full rounded-[inherit]\",\n          contentClassName\n        )}\n      >\n        {children}\n      </div>\n    </div>\n  );\n}\n\nexport { AnimatedBorder, type AnimatedBorderProps };\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "creative"
  ],
  "type": "registry:ui"
}