Installation
npx kinetic-ui-cli@latest add magnetic-tooltip
How It Works
The MagneticTooltip leverages framer-motion's useSpring and useMotionValue to track cursor position inside a bounding box. We then calculate the mathematical derivative (velocity) of the cursor's movement in real-time, and pass that value into a useTransform to dynamically scale, rotate, and squash the tooltip, giving it a true physical presence.
Usage Guide
1. Import the Component
Import the component into your React or Next.js page:
import { MagneticTooltip } from "@/components/creative/magnetic-tooltip";
2. Implementation Example
Render the component and customize its behavior by passing props:
import { MagneticTooltip } from "@/components/creative/magnetic-tooltip";
export default function Example() {
return (
<div className="w-full flex items-center justify-center p-8">
<MagneticTooltip
content="example"
tooltipClassName="example"
>
<div>Content goes here</div>
</MagneticTooltip>
</div>
);
}