Components/AI

Particle Animation

Interactive particle animation with customizable orbits, colors, and animation controls

Live Preview
Open in

Example

export default function ParticleAnimationExample() {
  const animationRef = useRef<ParticleAnimationHandle>(null);

  const handleStart = () => {
    animationRef.current?.startAnimation();
  };

  const handlePause = () => {
    animationRef.current?.pauseAnimation();
  };

  const handleResume = () => {
    animationRef.current?.resumeAnimation();
  };

  const handleStop = () => {
    animationRef.current?.stopAnimation();
  };

  return (
    <div className="space-y-4">
      <ParticleAnimation
        width={400}
        height={400}
        numParticles={150}
        minRadius={100}
        maxRadius={180}
        backgroundColor="rgba(0, 0, 0, 0.1)"
        particleColor="#3B82F6"
        brightParticleColor="#60A5FA"
        showCenter={true}
        showBorders={true}
        className="w-full"
        ref={animationRef}
      />
      
      <div className="flex gap-2">
        <button onClick={handleStart}>Start</button>
        <button onClick={handlePause}>Pause</button>
        <button onClick={handleResume}>Resume</button>
        <button onClick={handleStop}>Stop</button>
      </div>
    </div>
  )
}

Documentation

PropTypeDefaultDescription
widthnumber300Width of the animation container in pixels
heightnumber300Height of the animation container in pixels
numParticlesnumber120Number of particles to animate
minRadiusnumber80Minimum orbit radius for particles
maxRadiusnumber140Maximum orbit radius for particles
backgroundColorstring'transparent'Background color of the container
particleColorstring'#9CA3AF'Color of regular particles
brightParticleColorstring'#FFFFFF'Color of bright particles
showCenterbooleanfalseShow center point indicator
showBordersbooleanfalseShow orbit border circles
classNamestring''Additional CSS classes

Types

interface ParticleAnimationProps {
  width?: number;
  height?: number;
  numParticles?: number;
  minRadius?: number;
  maxRadius?: number;
  backgroundColor?: string;
  particleColor?: string;
  brightParticleColor?: string;
  showCenter?: boolean;
  showBorders?: boolean;
  className?: string;
}

interface ParticleAnimationHandle {
  startAnimation: () => void;
  pauseAnimation: () => void;
  resumeAnimation: () => void;
  stopAnimation: () => void;
}

Features

  • Orbital Animation: Particles rotate around a central point with customizable orbits
  • Pulse Effects: Dynamic size and opacity changes for visual appeal
  • Bright Particles: Special bright particles with glow effects
  • Animation Controls: Start, pause, resume, and stop functionality via ref
  • Dispersion Animation: Initial spread animation when starting
  • Customizable Colors: Configurable particle and background colors
  • Responsive Design: Adapts to different container sizes
  • Performance Optimized: Efficient animation loop with requestAnimationFrame