{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spotlight",
  "title": "Spotlight",
  "description": "A soft light that follows the pointer across a surface and along its edge.",
  "dependencies": [
    "@radix-ui/react-slot"
  ],
  "registryDependencies": [
    "@corsair-ui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/spotlight.tsx",
      "content": "\"use client\";\n\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport { useEffect, useRef, type ComponentProps, type CSSProperties } from \"react\";\n\nimport { cn } from \"@/registry/default/lib/utils\";\n\n// Two masks, one clipped to the content box: \"exclude\" keeps only the\n// padding, which is the 1px ring.\nconst RING_MASK = \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\";\n\nconst lightClassName = cn(\n  \"pointer-events-none absolute inset-0 -z-10 rounded-[inherit] opacity-0\",\n  \"transition-opacity duration-300 motion-reduce:transition-none\",\n  \"group-focus-within/spotlight:opacity-100 group-hover/spotlight:opacity-100\"\n);\n\ninterface SpotlightProps extends ComponentProps<\"div\"> {\n  /** Light the single child element, e.g. a Card, instead of wrapping it in a div. */\n  asChild?: boolean;\n  /** Radius of the light, in px. */\n  size?: number;\n  /** Colour of the light: any CSS colour, including theme variables. */\n  color?: string;\n  /** Also light the part of the edge nearest the pointer. */\n  ring?: boolean;\n}\n\n/**\n * A soft light that follows the pointer across a surface, and along its edge.\n * It sits behind the content (the element becomes its own stacking context)\n * and only updates two CSS variables per frame, so nothing re-renders. Touch\n * screens skip it; keyboard focus inside lights it where the pointer last was.\n *\n * @example\n * <Spotlight asChild>\n *   <Card>…</Card>\n * </Spotlight>\n */\nfunction Spotlight({\n  asChild = false,\n  size = 320,\n  color = \"var(--foreground)\",\n  ring = true,\n  className,\n  children,\n  onPointerMove,\n  ...props\n}: SpotlightProps) {\n  const frame = useRef(0);\n\n  useEffect(() => () => cancelAnimationFrame(frame.current), []);\n\n  const Comp = asChild ? Slot : \"div\";\n  const circle = `${size}px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%)`;\n  const ringStyle: CSSProperties = {\n    background: `radial-gradient(${circle}, color-mix(in oklab, ${color} 45%, transparent), transparent 60%)`,\n    mask: RING_MASK,\n    maskComposite: \"exclude\",\n    WebkitMask: RING_MASK,\n    WebkitMaskComposite: \"xor\",\n  };\n\n  return (\n    <Comp\n      data-slot=\"spotlight\"\n      className={cn(\"group/spotlight relative isolate\", className)}\n      onPointerMove={(event) => {\n        onPointerMove?.(event);\n        if (event.pointerType === \"touch\") return;\n        const target = event.currentTarget;\n        const { clientX, clientY } = event;\n        cancelAnimationFrame(frame.current);\n        frame.current = requestAnimationFrame(() => {\n          const bounds = target.getBoundingClientRect();\n          target.style.setProperty(\"--spotlight-x\", `${clientX - bounds.left}px`);\n          target.style.setProperty(\"--spotlight-y\", `${clientY - bounds.top}px`);\n        });\n      }}\n      {...props}\n    >\n      <span\n        aria-hidden=\"true\"\n        data-slot=\"spotlight-light\"\n        className={lightClassName}\n        style={{\n          background: `radial-gradient(${circle}, color-mix(in oklab, ${color} 10%, transparent), transparent 70%)`,\n        }}\n      />\n      {ring ? (\n        <span\n          aria-hidden=\"true\"\n          data-slot=\"spotlight-ring\"\n          className={cn(lightClassName, \"-inset-px p-px\")}\n          style={ringStyle}\n        />\n      ) : null}\n      <Slottable>{children}</Slottable>\n    </Comp>\n  );\n}\n\nexport { Spotlight, type SpotlightProps };\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "creative"
  ],
  "type": "registry:ui"
}