{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rainbow-button",
  "title": "Rainbow button",
  "description": "Button with a seamlessly flowing rainbow border and a soft colored glow underneath, tuned to invert cleanly between light and dark themes.",
  "dependencies": [],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json"
  ],
  "files": [
    {
      "path": "registry/components/buttons/rainbow-button.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\n// One gradient strip, twice the button width, slides by half its width so the loop is seamless (transform only).\nconst CSS = `\n@keyframes pc-rainbow-button-flow { to { transform: translateX(-50%) } }\n.pc-rainbow-button-strip {\n  position: absolute; top: 0; left: 0; height: 100%; width: 200%;\n  background: linear-gradient(90deg, var(--pc-rb-1), var(--pc-rb-2), var(--pc-rb-3), var(--pc-rb-4), var(--pc-rb-5), var(--pc-rb-1)) 0 0 / 50% 100% repeat-x;\n  animation: pc-rainbow-button-flow var(--pc-rb-speed, 3s) linear infinite;\n}\n.pc-rainbow-button-glow { opacity: .55; transition: opacity .3s, transform .3s }\n.pc-rainbow-button:hover .pc-rainbow-button-glow { opacity: .9; transform: translateY(2px) scaleX(1.04) }\n.dark .pc-rainbow-button-glow { opacity: .45 }\n.dark .pc-rainbow-button:hover .pc-rainbow-button-glow { opacity: .75 }\n@media (prefers-reduced-motion: reduce) { .pc-rainbow-button-strip { animation: none } }\n`\n\nconst DEFAULT_COLORS = [\"hsl(0 100% 63%)\", \"hsl(270 100% 63%)\", \"hsl(210 100% 63%)\", \"hsl(195 100% 63%)\", \"hsl(90 100% 63%)\"]\n\nconst SIZES = {\n  sm: { cls: \"h-8 px-3.5 text-xs gap-1.5 [&_svg]:size-3.5\", r: 10 },\n  md: { cls: \"h-10 px-5 text-sm gap-2 [&_svg]:size-4\", r: 12 },\n  lg: { cls: \"h-12 px-7 text-base gap-2 [&_svg]:size-5\", r: 14 },\n} as const\n\nexport type RainbowButtonProps = React.ComponentProps<\"button\"> & {\n  /** \"solid\" inverts with the theme (black in light, white in dark); \"outline\" uses the page background. */\n  variant?: \"solid\" | \"outline\"\n  /** \"sm\" | \"md\" | \"lg\": height, padding and corner radius (10, 12 or 14 px). */\n  size?: keyof typeof SIZES\n  /** Fully rounded ends. */\n  pill?: boolean\n  /** Five CSS colors for the flowing gradient. */\n  colors?: string[]\n  /** Seconds per loop. */\n  speed?: number\n  /** Border thickness in px. */\n  borderWidth?: number\n}\n\n/** Button with a flowing rainbow border and a soft colored glow underneath; tuned for light and dark themes. */\nexport function RainbowButton({\n  variant = \"solid\",\n  size = \"md\",\n  pill,\n  colors = DEFAULT_COLORS,\n  speed = 3,\n  borderWidth = 2,\n  className,\n  style,\n  children,\n  ...props\n}: RainbowButtonProps) {\n  const s = SIZES[size]\n  const r = pill ? 999 : s.r\n  const vars: Record<string, string | number> = { \"--pc-rb-speed\": `${speed}s` }\n  for (let i = 0; i < 5; i++) {\n    const c = colors[i % colors.length]\n    if (c !== undefined) vars[`--pc-rb-${i + 1}`] = c\n  }\n\n  return (\n    <button\n      data-slot=\"button\"\n      className={cn(\n        \"pc-press pc-rainbow-button group relative isolate inline-flex shrink-0 items-center justify-center font-medium whitespace-nowrap transition-transform outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0\",\n        variant === \"solid\" ? \"text-background\" : \"text-foreground\",\n        s.cls,\n        className,\n      )}\n      style={{ borderRadius: r, ...vars, ...style }}\n      {...props}\n    >\n      <GooduiTokens />\n      <style href=\"pc-rainbow-button\" precedence=\"default\">\n        {CSS}\n      </style>\n      {/* Glow */}\n      <span\n        aria-hidden=\"true\"\n        className=\"pc-rainbow-button-glow pointer-events-none absolute inset-x-[8%] -bottom-[18%] -z-10 h-3/5 overflow-hidden blur-[14px]\"\n        style={{ borderRadius: r }}\n      >\n        <span className=\"pc-rainbow-button-strip\" />\n      </span>\n      {/* Border */}\n      <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 -z-10 overflow-hidden\" style={{ borderRadius: r }}>\n        <span className=\"pc-rainbow-button-strip\" />\n      </span>\n      {/* Face */}\n      <span\n        aria-hidden=\"true\"\n        className={cn(\n          \"pointer-events-none absolute -z-10\",\n          variant === \"solid\"\n            ? \"bg-foreground bg-[linear-gradient(180deg,rgb(255_255_255/0.08),transparent_60%)] dark:bg-[linear-gradient(180deg,transparent_40%,rgb(0_0_0/0.06))]\"\n            : \"bg-background\",\n        )}\n        style={{ inset: borderWidth, borderRadius: Math.max(0, r - borderWidth) }}\n      />\n      {children}\n    </button>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/rainbow-button.tsx"
    }
  ],
  "categories": [
    "components",
    "buttons"
  ],
  "type": "registry:component"
}