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 MagneticScatterText

This 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

PropTypeDefaultDescription
textstringRequiredThe text content to animate
classNamestringundefinedAdditional styles for the container
triggerbooleantrueControls animation state (true = visible, false = hidden)