{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spotlight",
  "type": "registry:component",
  "title": "Spotlight",
  "description": "A surface on which a soft light in the highlight colour follows the pointer.",
  "categories": [
    "motion"
  ],
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn",
    "@rivier-ui/motion"
  ],
  "files": [
    {
      "path": "registry/motion/spotlight.tsx",
      "type": "registry:component",
      "target": "components/motion/spotlight.tsx",
      "content": "\"use client\";\n/**\n * @name spotlight\n * @category motion\n * @description A surface on which a soft light in the highlight colour follows the pointer.\n * @when A hero panel, a feature card or a call-to-action band that should respond to the pointer. Give it a border and a background like any surface. Decoration only: it does nothing on touch screens, so never rely on it to show something.\n * @example\n * <Spotlight className=\"rounded-surface border bg-card p-8\">\n *   <h3 className=\"text-xl font-medium\">Made to be changed</h3>\n *   <p className=\"text-muted-foreground\">Every component is yours to edit.</p>\n * </Spotlight>\n * <Spotlight size={640} className=\"rounded-surface border p-12\">…</Spotlight>\n */\nimport { motion, useMotionValue, useSpring } from \"motion/react\";\nimport { useEffect, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { SPRING, isFinePointer, useMotionSafe } from \"@/lib/motion\";\n\nexport type SpotlightProps = ComponentProps<\"div\"> & {\n  /** The diameter of the light, in pixels. Default 480. */\n  size?: number;\n};\n\n/**\n * The light is one element whose gradient is drawn once. Following the pointer only changes that element's\n * transform, and showing it only changes its opacity, so the surface is never repainted. It sits above the\n * surface's background and below its content (the root is its own stacking context).\n */\nexport function Spotlight({ className, size = 480, children, ref, ...props }: SpotlightProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  useImperativeHandle(ref, () => rootRef.current as HTMLDivElement, []);\n  const safe = useMotionSafe();\n  const x = useMotionValue(0);\n  const y = useMotionValue(0);\n  const opacity = useSpring(0, SPRING);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!safe || !root || !isFinePointer()) return;\n    const move = (event: PointerEvent): void => {\n      if (event.pointerType === \"touch\") return;\n      const rect = root.getBoundingClientRect();\n      x.set(event.clientX - rect.left - root.clientLeft);\n      y.set(event.clientY - rect.top - root.clientTop);\n      opacity.set(1);\n    };\n    const leave = (): void => opacity.set(0);\n    root.addEventListener(\"pointermove\", move, { passive: true });\n    root.addEventListener(\"pointerleave\", leave, { passive: true });\n    return () => {\n      root.removeEventListener(\"pointermove\", move);\n      root.removeEventListener(\"pointerleave\", leave);\n      opacity.jump(0);\n    };\n  }, [safe, x, y, opacity]);\n\n  return (\n    <div ref={rootRef} data-slot=\"spotlight\" className={cn(\"relative isolate overflow-hidden\", className)} {...props}>\n      <motion.div\n        aria-hidden=\"true\"\n        data-slot=\"spotlight-light\"\n        className=\"pointer-events-none absolute top-0 left-0 -z-10 rounded-full\"\n        style={{\n          width: size,\n          height: size,\n          marginLeft: -size / 2,\n          marginTop: -size / 2,\n          x,\n          y,\n          opacity,\n          backgroundImage: \"radial-gradient(closest-side, color-mix(in oklab, var(--highlight) 24%, transparent), transparent)\",\n        }}\n      />\n      {children}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "motion",
    "when": "A hero panel, a feature card or a call-to-action band that should respond to the pointer. Give it a border and a background like any surface. Decoration only: it does nothing on touch screens, so never rely on it to show something.",
    "example": "<Spotlight className=\"rounded-surface border bg-card p-8\">\n  <h3 className=\"text-xl font-medium\">Made to be changed</h3>\n  <p className=\"text-muted-foreground\">Every component is yours to edit.</p>\n</Spotlight>\n<Spotlight size={640} className=\"rounded-surface border p-12\">…</Spotlight>",
    "client": true
  }
}
