Join our Discord Community

React Psychedelic Spiral

Hypnotic spiral background with WebGL shaders that won't kill performance. Pure shader-based spiral effect for React with TypeScript and shadcn/ui—smooth GPU animations.

Powered by

Building hypnotic spiral effects?

Join our Discord community for help from other developers working with WebGL shaders.


Look, we've all tried to build psychedelic spiral backgrounds. You either end up with janky CSS animations that look nothing like proper mathematical spirals or JavaScript calculations that tank your frame rate. This React component uses WebGL fragment shaders that actually run at 60fps without melting your CPU.

Smooth spiral animation

Mesmerizing mathematical spiral effect that won't destroy your performance metrics:

Loading component...

Inspired by xxidbr9

Built for React applications with TypeScript and Next.js in mind. The animation runs entirely on the GPU using WebGL shaders, so your JavaScript thread stays free for actual logic. Works seamlessly with shadcn/ui design systems.

Installation

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

Usage

import { PsychedelicSpiral } from "@/components/ui/psychedelic-spiral";

export default function Hero() {
  return (
    <PsychedelicSpiral>
      <div className="relative z-10">
        <h1>Your content here</h1>
      </div>
    </PsychedelicSpiral>
  );
}

Why most spiral implementations suck

Most developers try to animate spirals with CSS transforms or JavaScript canvas drawing. Bad idea. You're calculating trigonometry on every frame, blocking the main thread, and wondering why your React app feels sluggish. Some use heavy animation libraries, which sounds smart until you realize you're loading megabytes for a background effect.

This React component uses mathematical fragment shaders with WebGL. The GPU handles everything. No JavaScript calculations, no frame drops, just smooth 60fps spiral mathematics. The colors use hex values that sync automatically with your Tailwind theme, so customization just works.

Features

  • Zero JavaScript animation overhead - Pure WebGL shaders run on GPU
  • Mathematical spiral generation with authentic trigonometric calculations
  • TypeScript definitions for proper IDE support in React projects
  • Three-color system with customizable hex colors and dynamic blending
  • Customizable parameters with 12+ props for complete control
  • Performance optimization through efficient shader rendering
  • shadcn/ui compatible for consistent design systems
  • Responsive design with automatic canvas resizing

API Reference

PsychedelicSpiral

Main container component for the spiral effect.

PropTypeDefaultDescription
spinRotationnumber-2.0Base spiral rotation speed (-10 to 10)
spinSpeednumber7.0Animation speed multiplier (0.1 to 20)
offset[number, number][0.0, 0.0]Pattern center offset (-1 to 1 each axis)
color1string"#DE443B"Primary spiral color (hex format)
color2string"#006BB4"Secondary spiral color (hex format)
color3string"#162325"Accent/highlight color (hex format)
contrastnumber3.5Pattern contrast intensity (1 to 10)
lightingnumber0.4Overall brightness level (0 to 2)
spinAmountnumber0.25Spiral compression factor (0 to 1)
pixelFilternumber745.0Render resolution filter (100 to 2000)
spinEasenumber1.0Spiral flow characteristics (0.1 to 5)
isRotatebooleanfalseEnable continuous animation
mouseInteractionbooleantrueEnable mouse-based distortion
classNamestring-Additional Tailwind CSS classes
...propsHTMLAttributes<HTMLDivElement>-All standard div props

Common gotchas

Animation not working: WebGL might not be supported in the browser. The component logs warnings when WebGL initialization fails. Check browser compatibility.

Performance issues on mobile: Some older phones struggle with complex shaders. Consider reducing the pixelFilter prop (try 400-500) or disabling animation on mobile devices.

Colors look wrong: The component uses hex color format only. RGB or HSL values need conversion to hex before passing to props.

Pattern looks pixelated: Lower pixelFilter values create intentional pixelation effects. Increase the pixelFilter prop (try 800-1200) for smoother patterns.

Spiral appears static: Make sure isRotate is set to true for animated spirals. Check that spinSpeed is not set to 0.

You might also like

Explore other animated background components for React applications:

Questions developers actually ask