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.
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:
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.
Prop | Type | Default | Description |
---|---|---|---|
spinRotation | number | -2.0 | Base spiral rotation speed (-10 to 10) |
spinSpeed | number | 7.0 | Animation speed multiplier (0.1 to 20) |
offset | [number, number] | [0.0, 0.0] | Pattern center offset (-1 to 1 each axis) |
color1 | string | "#DE443B" | Primary spiral color (hex format) |
color2 | string | "#006BB4" | Secondary spiral color (hex format) |
color3 | string | "#162325" | Accent/highlight color (hex format) |
contrast | number | 3.5 | Pattern contrast intensity (1 to 10) |
lighting | number | 0.4 | Overall brightness level (0 to 2) |
spinAmount | number | 0.25 | Spiral compression factor (0 to 1) |
pixelFilter | number | 745.0 | Render resolution filter (100 to 2000) |
spinEase | number | 1.0 | Spiral flow characteristics (0.1 to 5) |
isRotate | boolean | false | Enable continuous animation |
mouseInteraction | boolean | true | Enable mouse-based distortion |
className | string | - | Additional Tailwind CSS classes |
...props | HTMLAttributes<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:
Aurora
Northern lights effects with smooth CSS animations
Balatro Background
Hypnotic spiral patterns with WebGL shaders
Plasma Background
Organic plasma effects with fluid WebGL animations
Vortex
Swirling particle effects that create mesmerizing depth
Meteors
Falling star animations perfect for space themes
Waves
Fluid wave animations for ocean and water themes
Questions developers actually ask
React Paths Background
React SVG path background with floating abstract animations. Framer Motion creates depth and movement effects with TypeScript and shadcn/ui styling.
React Retro Grid Background
React retro grid background with 80s cyberpunk perspective. CSS infinite scrolling and neon colors create nostalgic vibes with TypeScript and shadcn/ui.