Overview
TheSpotlight component creates a dramatic spotlight visual effect using an SVG ellipse with Gaussian blur filtering. It’s designed to add atmospheric lighting to hero sections and background elements.
Visual Effect
The component renders:- A large, blurred elliptical light source
- Positioned absolutely for layering
- Animated movement via the
animate-spotlightTailwind animation - Semi-transparent fill (21% opacity by default)
Source Location
/workspace/source/src/app/components/ui/Spotlight.tsx
Props
Additional Tailwind classes to customize positioning and appearance. Merged with default classes using
cn() utility.SVG fill color for the spotlight ellipse. Accepts any valid CSS color value.
Type Definition
From/workspace/source/src/app/components/ui/Spotlight.tsx:4-7:
Default Styling
The component applies these default classes:Key style notes:
pointer-events-none: Allows clicks to pass through to underlying elementsabsolute: Requires parent with relative positioningz-[1]: Places spotlight just above base layer- Responsive width: 138% on mobile, 84% on large screens
SVG Structure
The SVG contains:- Viewbox:
0 0 3787 2842(fixed aspect ratio) - Ellipse: Transformed and rotated for directional lighting
- Filter: Gaussian blur with 151px standard deviation
Ellipse Parameters
From/workspace/source/src/app/components/ui/Spotlight.tsx:21-29:
Animation
The component relies on a Tailwind CSS custom animation named
animate-spotlight, which should be defined in your tailwind.config.js file.Usage Example
Customization Examples
Colored Spotlight
Multiple Spotlights
Technical Details
Filter Definition
From/workspace/source/src/app/components/ui/Spotlight.tsx:32-52:
Best Practices
- Parent Container: Always use within a positioned parent (
relative,absolute, orfixed) - Z-Index Management: Ensure content has higher z-index than the spotlight
- Performance: Use sparingly—SVG filters can impact rendering performance
- Dark Backgrounds: Works best against dark or black backgrounds for maximum contrast
Dependencies
@/lib/utils- Provides thecn()utility for class merging- React
- Tailwind CSS (for
animate-spotlightanimation)