Installation
- Tab Title
- Tab Title
Usage
Props
The content to display inside the card.
Additional CSS classes to apply to the card container.
Radius of the gradient spotlight effect in pixels.
Color of the overlay gradient spotlight.
Opacity of the gradient overlay (0-1).
Starting color of the border gradient (visible on hover).
Ending color of the border gradient (visible on hover).
Examples
Basic Card
Custom Colors
Larger Spotlight
Lower Opacity
Card Grid
Feature Showcase
How It Works
The Magic Card creates a layered effect:- Border Layer: Animated gradient that follows the mouse
- Background Layer: Fills the card interior
- Overlay Layer: Semi-transparent spotlight effect
- Content Layer: Your card content on top
motion-sv with useMotionTemplate and useMotionValue for smooth, performance-optimized animations.
Mouse Tracking
The component automatically:- Tracks mouse position within the card
- Updates gradient positions in real-time
- Resets when the mouse leaves the card
- Handles window blur and visibility changes
- Works with touch/pointer events
Features
- Mouse-following spotlight effect
- Animated gradient border
- Customizable gradient colors and size
- Smooth transitions with motion-sv
- Automatic cleanup and reset handling
- Responsive to visibility changes
- GPU-accelerated animations
- Semantic HTML structure
- Accessible with proper ARIA roles
Styling Tips
- The card inherits border radius from parent styles
- Use
rounded-lg,rounded-xl, etc. on the parent for rounded corners - The component uses CSS custom properties for border colors
- Combine with other utility classes for spacing and layout
Performance
- Uses
transform-gpufor hardware acceleration - Efficient pointer event tracking
- Automatic cleanup of event listeners
- Minimal re-renders with reactive motion values