Magnetic Scatter Text
An interactive text animation that scatters on hover with magnetic spring effects.
Hover Me
Installation
Run the following command to install the component:
npx rareui add MagneticScatterTextThis will install the component to components/rareui/ directory.
Usage
import { MagneticScatterText } from "@/components/rareui/Text Animation/MagneticScatterText";
export default function MyComponent() {
return (
<MagneticScatterText text="Your Text" className="text-6xl" />
);
}
Examples
With Trigger Control
"use client";
import { useState } from 'react';
import { MagneticScatterText } from "@/components/rareui/Text Animation/MagneticScatterText";
export default function ControlledAnimation() {
const [show, setShow] = useState(false);
return (
<div>
<button onClick={() => setShow(!show)}>
Toggle Animation
</button>
<MagneticScatterText
text="Click to animate"
trigger={show}
className="text-6xl text-foreground"
/>
</div>
);
}
Custom Styling
<MagneticScatterText
text="Magnetic"
className="text-9xl font-bold text-blue-500"
/>
Features
- Magnetic Spring Animation: Letters gather from scattered positions with spring physics
- Interactive Hover: Slight scatter effect when hovering over the text
- Deterministic Random: Consistent scatter pattern based on letter position
- Smooth Transitions: Spring-based animations for natural movement
- Fully Customizable: Control trigger state and styling
Props
| Prop | Type | Default | Description |
|---|---|---|---|
text | string | Required | The text content to animate |
className | string | undefined | Additional styles for the container |
trigger | boolean | true | Controls animation state (true = visible, false = hidden) |