Installation
- Tab Title
- Tab Title
Usage
Props
The content to be zoomed. Typically an image, video, or any HTML element.
Additional CSS classes to apply to the container.
The magnification factor for the zoomed area. Must be greater than 1.
Diameter of the lens in pixels. Must be greater than 0.
Controlled position of the lens. Used for external position control.
Default position where the lens appears when not hovering. When set, the lens is always visible.
When true, the lens remains at a fixed position and doesn’t follow the mouse.
Duration of the lens entrance/exit animation in seconds.
Color of the lens mask. Can be any valid CSS color.
Accessible label for the lens region.
Examples
Basic Image Zoom
Higher Zoom Factor
Static Lens Position
Default Position (Always Visible)
Custom Lens Color
With Video Content
Custom Animation Duration
Keyboard Support
- Escape: Hides the lens when hovering
How It Works
- The component creates a masked overlay layer
- The overlay contains a scaled copy of the children
- The mask follows the mouse cursor (or stays at a fixed position)
- CSS transforms handle the zoom effect
- AnimatePresence provides smooth entrance/exit animations
Features
- Smooth mouse-following lens effect
- Customizable zoom level and lens size
- Static and dynamic positioning modes
- Default position for always-visible lens
- Keyboard accessibility (Escape to dismiss)
- Works with images, videos, and any HTML content
- Smooth animations with configurable duration
- Proper focus management
- Validates props to prevent invalid configurations
Accessibility
- The container has
role="region"for semantic structure - Custom
aria-labelsupport for better screen reader experience - Keyboard navigation with Escape key
- Focusable with
tabindex="0"
Performance Tips
- For large images, consider using optimized image formats (WebP, AVIF)
- Use appropriate
zoomFactorvalues (1.3-2.5 is typically sufficient) - Keep
lensSizereasonable (100-300px) for best performance - The component uses CSS transforms for GPU-accelerated rendering