Hover me
The SpotLight component creates a beautiful spotlight effect that follows your mouse cursor, perfect for cards, buttons, and interactive elements that need an elegant hover state
Installation
1npx shadcn@latest add "https://ace-ui-six.vercel.app/r/spotlight.json"
Usage
1import { SpotLight } from "@/components/ui/spot-light";23export default function Example() {4return (5 <div>6 <SpotLight7 className="h-52 w-40 flex justify-center items-center bg-black border border-white"8 spotlightColor="rgba(151, 151, 151, 0.1)"9 >10 Hover me11 </SpotLight>12 </div>13);14}
Features
- Smooth spotlight effect that follows mouse movement
- Customizable spotlight color with RGBA support
- Responsive to mouse enter, leave, focus, and blur events
- Fade in/out animations for smooth transitions
- TypeScript support with proper type definitions
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | "Hover me" | Content to display inside the spotlight container |
className | string | "h-52 w-40 flex justify-center items-center bg-black border border-white" | CSS classes for styling the container |
spotlightColor | string | 'rgba(151, 151, 151, 0.1)' | Color of the spotlight effect in RGBA format |
Color Examples
Here are some popular spotlight color combinations:
1// Subtle gray (default)2spotlightColor="rgba(151, 151, 151, 0.1)"34// Blue accent5spotlightColor="rgba(59, 130, 246, 0.15)"67// Purple glow8spotlightColor="rgba(168, 85, 247, 0.2)"910// Green highlight11spotlightColor="rgba(34, 197, 94, 0.1)"1213// Red warning14spotlightColor="rgba(239, 68, 68, 0.12)"1516// Gold premium17spotlightColor="rgba(245, 158, 11, 0.15)"1819// Cyan modern20spotlightColor="rgba(6, 182, 212, 0.1)"