This component no longer exists. It was in motion-primitives’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-06 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
Spotlight
motion-primitives/spotlightRemovedComponent
A component that creates a spotlight effect following cursor movement.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/ibelick/motion-primitives/HEAD/public/c/spotlight.jsonSource
1'use client';2import React, { useRef, useState, useCallback, useEffect } from 'react';3import { motion, useSpring, useTransform, SpringOptions } from 'motion/react';4import { cn } from '@/lib/utils';56export type SpotlightProps = {7 className?: string;8 size?: number;9 springOptions?: SpringOptions;10};1112export function Spotlight({13 className,14 size = 200,15 springOptions = { bounce: 0 },16}: SpotlightProps) {17 const containerRef = useRef<HTMLDivElement>(null);18 const [isHovered, setIsHovered] = useState(false);19 const [parentElement, setParentElement] = useState<HTMLElement | null>(null);2021 const mouseX = useSpring(0, springOptions);22 const mouseY = useSpring(0, springOptions);2324 const spotlightLeft = useTransform(mouseX, (x) => `${x - size / 2}px`);25 const spotlightTop = useTransform(mouseY, (y) => `${y - size / 2}px`);2627 useEffect(() => {28 if (containerRef.current) {29 const parent = containerRef.current.parentElement;30 if (parent) {31 parent.style.position = 'relative';32 parent.style.overflow = 'hidden';33 setParentElement(parent);34 }35 }36 }, []);3738 const handleMouseMove = useCallback(39 (event: MouseEvent) => {40 if (!parentElement) return;41 const { left, top } = parentElement.getBoundingClientRect();42 mouseX.set(event.clientX - left);43 mouseY.set(event.clientY - top);44 },45 [mouseX, mouseY, parentElement]46 );4748 useEffect(() => {49 if (!parentElement) return;5051 const abortController = new AbortController();5253 parentElement.addEventListener('mousemove', handleMouseMove, {54 signal: abortController.signal,55 });56 parentElement.addEventListener('mouseenter', () => setIsHovered(true), {57 signal: abortController.signal,58 });59 parentElement.addEventListener('mouseleave', () => setIsHovered(false), {60 signal: abortController.signal,61 });6263 return () => {64 abortController.abort();65 };66 }, [parentElement, handleMouseMove]);6768 return (69 <motion.div70 ref={containerRef}71 className={cn(72 'pointer-events-none absolute rounded-full bg-[radial-gradient(circle_at_center,var(--tw-gradient-stops),transparent_80%)] blur-xl transition-opacity duration-200',73 'from-zinc-100 via-zinc-200 to-zinc-400 dark:from-zinc-50 dark:via-zinc-100 dark:to-zinc-200',74 isHovered ? 'opacity-100' : 'opacity-0',75 className76 )}77 style={{78 width: size,79 height: size,80 left: spotlightLeft,81// … truncated
What it pulls in
npm packages
