Skip to main content

Overview

MagneticScatterText splits your text into individual characters and animates each one independently using Framer Motion spring physics. On hover, letters scatter in deterministic directions based on their index, then snap back elastically — creating a magnetic pull effect.

Installation

Requires framer-motion as a peer dependency.

Usage

Props

string
required
The text content to animate. Each character is split and animated independently.
boolean
default:"true"
Controls the animation state. When true the text assembles into view; when false it scatters away.
string
Additional Tailwind or CSS classes applied to the container div. Use this to control font size, color, weight, and spacing.

Examples

Basic hover scatter

Controlled trigger animation

Custom styled headline

Features

Magnetic Scattering

Characters fly apart in deterministic directions on hover, then spring back to their positions.

Deterministic Randomness

Scatter offsets are derived from character index using a seeded algorithm — consistent across renders.

Trigger Control

Programmatically show or hide the text via the trigger prop, useful for scroll-driven reveals.

Spring Physics

Entry and scatter animations use Framer Motion spring physics with configurable damping, stiffness, and mass.