{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spotlight-card",
  "title": "Spotlight card",
  "description": "A soft spotlight and a lit border follow the pointer across a card; in a group, neighboring cards' borders light up too.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/cards/spotlight-card.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n// ::before is the soft fill under the content, ::after lights up only the border ring (mask exclude trick).\nconst CSS = `\n.pc-spotlight-card { --pc-x: -1000px; --pc-y: -1000px; position: relative; isolation: isolate }\n.pc-spotlight-card::before, .pc-spotlight-card::after {\n  content: \"\"; position: absolute; pointer-events: none; border-radius: inherit;\n  opacity: 0; transition: opacity 0.35s ease;\n}\n.pc-spotlight-card::before {\n  inset: 0; z-index: -1;\n  background: radial-gradient(var(--pc-spot-size, 360px) circle at var(--pc-x) var(--pc-y), var(--pc-spot-fill, color-mix(in oklch, var(--foreground) 7%, transparent)), transparent 70%);\n}\n.pc-spotlight-card::after {\n  inset: calc(var(--pc-spot-bw, 1px) * -1); padding: var(--pc-spot-bw, 1px); z-index: 1;\n  background: radial-gradient(calc(var(--pc-spot-size, 360px) * 0.75) circle at calc(var(--pc-x) + var(--pc-spot-bw, 1px)) calc(var(--pc-y) + var(--pc-spot-bw, 1px)), var(--pc-spot-border, color-mix(in oklch, var(--foreground) 50%, transparent)), transparent 70%);\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-spotlight-card[data-active]::before, .pc-spotlight-card[data-active]::after { opacity: 1 }\n.pc-spotlight-card[data-linked]:not([data-hovered])::before { opacity: 0 }\n@media (prefers-reduced-motion: reduce) { .pc-spotlight-card::before, .pc-spotlight-card::after { transition: none } }\n`\n\nconst GroupContext = React.createContext(false)\n\nfunction place(card: HTMLElement, clientX: number, clientY: number) {\n  const r = card.getBoundingClientRect()\n  card.style.setProperty(\"--pc-x\", `${clientX - r.left}px`)\n  card.style.setProperty(\"--pc-y\", `${clientY - r.top}px`)\n}\n\nexport type SpotlightCardProps = React.HTMLAttributes<HTMLDivElement> & {\n  /** Fill color of the soft spotlight. */\n  spotlightColor?: string\n  /** Color of the lit border. */\n  borderColor?: string\n  /** Diameter of the spotlight in px. */\n  size?: number\n  /** Border width the highlight should cover, in px (match the card's border). */\n  borderWidth?: number\n}\n\n/** A card with a soft radial spotlight and a lit border that follow the pointer. CSS variables only, no re-renders. */\nexport function SpotlightCard({\n  spotlightColor,\n  borderColor,\n  size = 360,\n  borderWidth = 1,\n  className,\n  style,\n  children,\n  onPointerMove,\n  onPointerEnter,\n  onPointerLeave,\n  ...props\n}: SpotlightCardProps) {\n  const linked = React.useContext(GroupContext)\n  return (\n    <>\n      <style href=\"pc-spotlight-card\" precedence=\"default\">\n        {CSS}\n      </style>\n      <div\n        data-pc-spotlight=\"\"\n        data-linked={linked ? \"\" : undefined}\n        className={cn(\"pc-spotlight-card rounded-xl border bg-card text-card-foreground\", className)}\n        style={{\n          ...style,\n          [\"--pc-spot-size\" as string]: `${size}px`,\n          [\"--pc-spot-bw\" as string]: `${borderWidth}px`,\n          ...(spotlightColor ? { [\"--pc-spot-fill\" as string]: spotlightColor } : {}),\n          ...(borderColor ? { [\"--pc-spot-border\" as string]: borderColor } : {}),\n        }}\n        onPointerEnter={(e) => {\n          if (linked) e.currentTarget.setAttribute(\"data-hovered\", \"\")\n          else e.currentTarget.setAttribute(\"data-active\", \"\")\n          onPointerEnter?.(e)\n        }}\n        onPointerMove={(e) => {\n          if (!linked) place(e.currentTarget, e.clientX, e.clientY)\n          onPointerMove?.(e)\n        }}\n        onPointerLeave={(e) => {\n          e.currentTarget.removeAttribute(linked ? \"data-hovered\" : \"data-active\")\n          onPointerLeave?.(e)\n        }}\n        {...props}\n      >\n        {children}\n      </div>\n    </>\n  )\n}\n\nexport type SpotlightGroupProps = React.HTMLAttributes<HTMLDivElement>\n\n/**\n * Links the spotlight of every SpotlightCard inside it: moving over the group lights the borders of nearby cards\n * too, while only the hovered card gets the fill.\n */\nexport function SpotlightGroup({ className, children, onPointerMove, onPointerLeave, ...props }: SpotlightGroupProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const frame = React.useRef(0)\n  React.useEffect(() => () => cancelAnimationFrame(frame.current), [])\n\n  return (\n    <GroupContext.Provider value={true}>\n      <div\n        ref={ref}\n        className={cn(className)}\n        onPointerMove={(e) => {\n          const { clientX, clientY } = e\n          cancelAnimationFrame(frame.current)\n          frame.current = requestAnimationFrame(() => {\n            ref.current?.querySelectorAll<HTMLElement>(\"[data-pc-spotlight]\").forEach((card) => {\n              place(card, clientX, clientY)\n              card.setAttribute(\"data-active\", \"\")\n            })\n          })\n          onPointerMove?.(e)\n        }}\n        onPointerLeave={(e) => {\n          cancelAnimationFrame(frame.current)\n          ref.current?.querySelectorAll<HTMLElement>(\"[data-pc-spotlight]\").forEach((card) => card.removeAttribute(\"data-active\"))\n          onPointerLeave?.(e)\n        }}\n        {...props}\n      >\n        {children}\n      </div>\n    </GroupContext.Provider>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/spotlight-card.tsx"
    }
  ],
  "categories": [
    "components",
    "cards"
  ],
  "type": "registry:component"
}