{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "border-beam-button",
  "title": "Border beam button",
  "description": "A short light beam rides around the button's rounded border with CSS offset-path, with a conic fallback and a static gradient for reduced motion.",
  "dependencies": [],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json"
  ],
  "files": [
    {
      "path": "registry/components/buttons/border-beam-button.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\n// The ring is masked to the border band. Inside it a short gradient \"beam\" rides the rounded-rect edge with\n// offset-path; browsers without offset-path rect() get a rotating conic sweep instead.\nconst CSS = `\n.pc-border-beam-button-ring {\n  position: absolute; inset: 0; border-radius: inherit; padding: var(--pc-bb-width); pointer-events: none;\n  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor; mask-composite: exclude;\n}\n.pc-border-beam-button-beam {\n  position: absolute; display: none; width: var(--pc-bb-size); aspect-ratio: 1;\n  background: linear-gradient(to left, var(--pc-bb-from), var(--pc-bb-to), transparent);\n  offset-path: rect(0 auto auto 0 round var(--pc-bb-radius)); offset-anchor: 90% 50%;\n  animation: pc-border-beam-button-travel var(--pc-bb-duration) linear infinite;\n}\n.pc-border-beam-button-spin {\n  position: absolute; left: 50%; top: 50%; width: 300%; aspect-ratio: 1; margin: -150% 0 0 -150%;\n  background: conic-gradient(from 0deg, transparent 0 72%, var(--pc-bb-to) 88%, var(--pc-bb-from) 98%, transparent 100%);\n  animation: pc-border-beam-button-spin var(--pc-bb-duration) linear infinite;\n}\n.pc-border-beam-button-late { animation-delay: calc(var(--pc-bb-duration) / -2) }\n@keyframes pc-border-beam-button-travel { from { offset-distance: 0% } to { offset-distance: 100% } }\n@keyframes pc-border-beam-button-spin { to { transform: rotate(360deg) } }\n@supports (offset-path: rect(0 auto auto 0)) {\n  .pc-border-beam-button-beam { display: block }\n  .pc-border-beam-button-spin { display: none }\n}\n@media (prefers-reduced-motion: reduce) {\n  .pc-border-beam-button-beam, .pc-border-beam-button-spin { display: none !important }\n  .pc-border-beam-button-ring { background: linear-gradient(90deg, var(--pc-bb-from), var(--pc-bb-to)); opacity: .55 }\n}\n`\n\nconst SIZES = {\n  sm: \"h-8 gap-1.5 px-3 text-xs [&_svg]:size-3.5\",\n  md: \"h-10 gap-2 px-4 text-sm [&_svg]:size-4\",\n  lg: \"h-12 gap-2 px-6 text-base [&_svg]:size-5\",\n} as const\n\nexport type BorderBeamButtonProps = React.ComponentProps<\"button\"> & {\n  /** \"outline\" is a page-colored face with a hairline border; \"solid\" fills with the primary color. */\n  variant?: \"outline\" | \"solid\"\n  /** \"sm\" | \"md\" | \"lg\": height and padding of the button. */\n  size?: keyof typeof SIZES\n  /** Corner radius in px (use 999 for a pill). Kept in sync with the beam path. */\n  radius?: number\n  /** Head color of the beam. */\n  colorFrom?: string\n  /** Tail color of the beam. */\n  colorTo?: string\n  /** Seconds per lap. */\n  duration?: number\n  /** Beam length in px. */\n  beamSize?: number\n  /** Border thickness in px. */\n  borderWidth?: number\n  /** Two beams chasing each other half a lap apart. */\n  double?: boolean\n}\n\n/** Button with a short light beam that travels around its border. CSS only; static gradient border for reduced motion. */\nexport function BorderBeamButton({\n  variant = \"outline\",\n  size = \"md\",\n  radius = 10,\n  colorFrom = \"#ffaa40\",\n  colorTo = \"#9c40ff\",\n  duration = 4,\n  beamSize = 56,\n  borderWidth = 1.5,\n  double,\n  className,\n  style,\n  children,\n  ...props\n}: BorderBeamButtonProps) {\n  const vars = {\n    \"--pc-bb-from\": colorFrom,\n    \"--pc-bb-to\": colorTo,\n    \"--pc-bb-duration\": `${duration}s`,\n    \"--pc-bb-size\": `${beamSize}px`,\n    \"--pc-bb-width\": `${borderWidth}px`,\n    \"--pc-bb-radius\": `${radius}px`,\n  } as React.CSSProperties\n\n  return (\n    <button\n      data-slot=\"button\"\n      className={cn(\n        \"pc-press relative isolate inline-flex shrink-0 items-center justify-center font-medium whitespace-nowrap transition-[background-color,box-shadow,transform] outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0\",\n        variant === \"outline\"\n          ? \"bg-background text-foreground shadow-[inset_0_0_0_1px_var(--border),0_1px_2px_rgb(0_0_0/0.05)] hover:bg-muted/60 dark:bg-input/20 dark:hover:bg-input/40\"\n          : \"bg-primary text-primary-foreground shadow-[var(--pc-e1)] hover:bg-primary/90\",\n        SIZES[size],\n        className,\n      )}\n      style={{ borderRadius: radius, ...vars, ...style }}\n      {...props}\n    >\n      <GooduiTokens />\n      <style href=\"pc-border-beam-button\" precedence=\"default\">\n        {CSS}\n      </style>\n      <span aria-hidden=\"true\" className=\"pc-border-beam-button-ring\">\n        <span className=\"pc-border-beam-button-beam\" />\n        <span className=\"pc-border-beam-button-spin\" />\n        {double && (\n          <>\n            <span className=\"pc-border-beam-button-beam pc-border-beam-button-late\" />\n            <span className=\"pc-border-beam-button-spin pc-border-beam-button-late\" />\n          </>\n        )}\n      </span>\n      {children}\n    </button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/border-beam-button.tsx"
    }
  ],
  "categories": [
    "components",
    "buttons"
  ],
  "type": "registry:component"
}