Join our Discord Community

Spiral Animation Background

Hypnotic spiral patterns that draw eyes into infinite mathematical beauty. Build mesmerizing React canvas animations with GSAP timelines, smooth motion curves, responsive sizing, and TypeScript support for Next.js applications with shadcn/ui.

Creating hypnotic visual experiences?

Join our Discord community for help from other developers.


Most animations are predictable. Linear. Boring. But spirals? Spirals tap into something primal—the same mathematical patterns found in galaxies, seashells, and DNA. This React component creates infinite spiral animations that draw viewers into hypnotic mathematical beauty, perfect for meditation apps, loading screens, or anywhere you need to captivate attention.

Infinite mathematical spirals

Watch perfect geometric spirals unfold with smooth GSAP-powered motion:

Loading component...

Built for React applications with TypeScript and Next.js. Uses HTML5 Canvas with GSAP timeline animations for professional-grade smooth motion. Mathematical spiral calculations create perfect geometric patterns that loop infinitely. Responsive canvas adapts to any container size. Perfect for loading screens, hero sections, or artistic installations.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/spiral-animation.json
npx shadcn@latest add https://www.shadcn.io/registry/spiral-animation.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/spiral-animation.json
bunx shadcn@latest add https://www.shadcn.io/registry/spiral-animation.json

Usage

import { SpiralAnimation } from "@/components/ui/spiral-animation";

export default function MeditationApp() {
  return (
    <div className="flex items-center justify-center h-screen bg-black">
      {/* Spiral animation */}
      <SpiralAnimation
        width={400}
        height={400}
        className="rounded-lg shadow-2xl"
      />

      {/* Optional overlay content */}
      <div className="absolute inset-0 flex items-center justify-center">
        <div className="text-white text-center z-10">
          <h1 className="text-4xl font-bold mb-4">Find Your Center</h1>
          <p className="text-xl opacity-80">Let the spiral guide your focus</p>
        </div>
      </div>
    </div>
  );
}

Why most spiral animations look amateur

Most developers use CSS transforms with rotate() and linear timing. It's rigid, mechanical, obviously computer-generated. Others try JavaScript with setInterval or basic requestAnimationFrame, but the motion is choppy and inconsistent. Some use SVG animations, but they lack the smooth mathematical precision of real spirals.

This React component uses GSAP timeline animations with professional easing curves. Mathematical spiral calculations ensure perfect geometric progression. Canvas rendering provides pixel-perfect control at 60fps. GSAP handles the complex timing and motion interpolation that makes the difference between amateur and professional animation.

Features

  • Mathematical spiral precision using algorithmic calculations for perfect geometric patterns
  • GSAP timeline animation providing professional-grade smooth motion with advanced easing
  • Canvas-based rendering delivering high-performance graphics with hardware acceleration
  • Infinite loop design creating seamless, mesmerizing continuous motion patterns
  • Responsive canvas sizing automatically adapting to container dimensions and window changes
  • Professional motion curves using GSAP's advanced easing functions for organic movement
  • Performance optimized leveraging requestAnimationFrame and efficient canvas operations
  • TypeScript definitions for all sizing and styling customization parameters
  • Zero configuration working beautifully with sensible defaults out of the box
  • shadcn/ui compatible with proper container styling and theme integration

API Reference

SpiralAnimation

Main component for GSAP-powered canvas-based spiral animations.

PropTypeDefaultDescription
widthnumber400Canvas width in pixels (recommended: 200-800)
heightnumber400Canvas height in pixels (recommended: 200-800)
classNamestring-Additional CSS classes for the canvas element

Note: This component has a minimal API focused on essential sizing. The spiral pattern, colors, and animation timing are optimized internally for the best hypnotic effect.

Mathematical Spiral Details

The spiral animation uses precise mathematical formulas:

// Archimedean spiral equation
r = a + b * θ;

// Parametric coordinates
x = r * cos(θ);
y = r * sin(θ);

// Where:
// θ = angle (continuously increasing)
// a = starting radius
// b = spiral tightness factor
// r = distance from center

GSAP Timeline Configuration

// Professional easing and timing
timeline.to(spiralParams, {
  rotation: 360,
  duration: 10,
  ease: "power2.inOut",
  repeat: -1,
  yoyo: true,
});

Optimal Sizing Guidelines

// Small accent spiral
width={200} height={200}

// Medium focal point
width={400} height={400} // Default, most balanced

// Large immersive experience
width={600} height={600}

// Full-screen meditation mode
width={800} height={800}

Common gotchas

GSAP dependency requirement: This component requires GSAP as a peer dependency (~40kb gzipped). If your project doesn't use GSAP elsewhere, consider the bundle size impact.

Canvas sizing performance: Very large canvases (1000x1000+) can impact performance on older devices. The mathematical calculations and redrawing become expensive at extreme sizes.

Container positioning: The canvas renders as a block element. For precise positioning, wrap it in a positioned container with appropriate CSS.

Animation timing conflicts: GSAP creates its own animation timeline. If you have other GSAP animations, be mindful of timeline conflicts and memory usage.

Mobile device performance: Complex spiral calculations can drain battery on mobile devices. Consider reducing size or pausing animations when the tab isn't visible.

Accessibility considerations: Spiral animations can trigger motion sensitivity or vertigo in some users. Consider adding motion preference detection.

You might also like

Explore other hypnotic and mathematical background components for React applications:

Questions developers actually ask