
The MagneticWrapper component adds an engaging interactive effect to child elements, simulating a magnetic attraction-like motion that follows the user's cursor.
Installation
Examples
Props
Prop | Type | Description | Default |
---|---|---|---|
children | ReactElement | The child element that will have the magnetic interaction applied. | - |
animationDuration | number | Duration of the magnetic effect animation in seconds. | 1 |
elasticity | number | Elasticity factor controlling the bounciness of the magnetic effect. | 0.3 |
Basic Usage
import MagneticWrapper from "@/components/magnetic-wrapper";
export default function Example() {
return (
<MagneticWrapper animationDuration={1.2} elasticity={0.5}>
<button className="btn">Hover Me!</button>
</MagneticWrapper>
);
}