Animated Tooltip
TheAnimatedTooltip component provides an elegant, physics-based tooltip that appears on hover with smooth spring animations. It features dynamic rotation and translation effects based on mouse position, creating an engaging micro-interaction powered by Framer Motion.
Installation
Import
Usage
Props
React.ReactNode
required
The content to display inside the tooltip trigger (typically an icon).
string
required
The text to display in the tooltip when hovering.
() => void
Optional click handler function.
string
Additional CSS classes to apply to the trigger element.
number
default:"100"
Delay in milliseconds before showing the tooltip on hover.
Animation Details
The component uses Framer Motion with sophisticated spring physics:Spring Configuration
Motion Values
- Rotation: Maps mouse position from -25° to 25° based on horizontal movement
- Translation: Subtle horizontal shift (-10px to 10px) following cursor
- Scale: Hover trigger scales to 1.2x, tap scales to 0.9x
Tooltip Animations
The tooltip automatically positions itself above the trigger and resets when the mouse leaves.
Examples
Icon Grid
Custom Styled
Accessibility
- Uses semantic HTML with proper ARIA attributes
- Keyboard accessible with tap interactions
- Respects user motion preferences
- Automatic cleanup of timers on unmount