Join our Discord Community

React Iridescence Background

React iridescence background with WebGL shader effects. Features dynamic color shifting, mouse-responsive patterns, and mathematical wave algorithms for stunning holographic visuals.

Powered by

Creating holographic interfaces?

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


Ever wanted to recreate that mesmerizing iridescent shimmer you see on soap bubbles, oil slicks, or holographic surfaces? Those dynamic rainbow patterns that shift and flow with organic beauty, creating depth and dimension through pure mathematics? The way colors blend and dance in impossible gradients that seem to have their own consciousness? Most visual effects rely on static gradients or simple animations, but they lack the sophisticated mathematical complexity that creates truly hypnotic iridescent patterns.

This React component creates that captivating iridescent effect using WebGL shaders with OGL library, featuring dynamic color shifting, mouse-responsive distortion, and mathematical wave algorithms that bring holographic magic to your interface.

Dynamic holographic patterns with mouse interaction

Watch iridescent colors flow and shift with mathematical precision and cursor responsiveness:

Loading component...

Built for React applications with TypeScript and optimized WebGL rendering. Uses advanced GLSL shaders with trigonometric functions for authentic iridescent color generation while providing intuitive controls for speed, amplitude, and color tinting. Perfect for premium interfaces, artistic showcases, or any application needing that luxurious holographic aesthetic.

Installation

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

Why static gradients feel artificial

Developers create rainbow gradients with CSS and consider them iridescent. Maybe they add some basic animation or color transitions. The problem? Static gradients can't capture the organic, mathematical nature of true iridescence that emerges from wave interference patterns and optical phenomena.

Shader-based iridescence with WebGL changes everything. It taps into the fundamental physics of light—the way waves interfere and create constructive patterns, how mathematical functions generate organic flow, the hypnotic beauty that emerges from trigonometric chaos. The algorithms use real mathematical wave functions and interference patterns to create authentic optical effects.

This component handles complex shader mathematics automatically. Trigonometric wave generation, color space manipulation, mouse coordinate transformation, and interference pattern calculations all work together seamlessly. The result feels like watching actual light phenomena through your screen.

Features

  • WebGL shader rendering with advanced GLSL for real-time iridescent pattern generation
  • Mathematical wave algorithms using trigonometric functions for authentic optical effects
  • Dynamic color shifting with customizable color tinting and intensity control
  • Mouse-responsive distortion with amplitude-based pattern modification
  • Interference patterns using iterative wave calculations for organic flow
  • Configurable animation speed with precise timing control for different visual rhythms
  • Color space optimization with efficient GPU-based color calculations
  • Performance optimization with WebGL context management and efficient rendering
  • Responsive design with automatic canvas scaling and device pixel ratio handling
  • Memory management with proper WebGL context disposal and resource cleanup

API Reference

Iridescence

PropTypeDefaultDescription
color[number, number, number][1, 1, 1]RGB color tint (0-1 values)
speednumber1.0Animation speed multiplier
amplitudenumber0.1Mouse interaction strength (0-1)
mouseReactbooleantrueEnable mouse responsiveness
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All standard div props

Color Configurations

Different color tints for various aesthetic themes:

ThemeColor ValuesEffect
Pure[1, 1, 1]Natural rainbow spectrum
Warm[1, 0.8, 0.6]Orange-pink tones
Cool[0.6, 0.8, 1]Blue-cyan tones
Magenta[1, 0.8, 0.9]Pink-purple spectrum
Electric[0.8, 1, 0.9]Green-cyan glow

Animation Settings

Different speed and amplitude combinations for various effects:

EffectSpeedAmplitudeDescription
Subtle0.50.05Gentle, slow shimmer
Standard1.00.1Balanced animation
Dynamic1.50.2Active, responsive
Intense2.00.3Fast, dramatic shifts

Shader mathematics

Wave Interference: Uses iterative trigonometric functions with phase shifting to create constructive and destructive interference patterns that mimic natural optical phenomena.

Color Generation: Implements mathematical color space transformations using cosine functions to generate smooth, organic color transitions across the spectrum.

Mouse Integration: Transforms screen coordinates to normalized UV space with amplitude scaling for consistent interaction across different container sizes.

Temporal Animation: Uses time-based phase offsets with configurable speed multipliers to create smooth, continuous animation loops without repetition artifacts.

Performance considerations

WebGL Optimization: Uses efficient GLSL shader compilation with optimized uniform updates and minimal state changes for consistent 60fps performance.

Fragment Shader Efficiency: Implements mathematical optimizations including loop unrolling and function inlining to reduce GPU computation overhead.

Memory Management: Properly handles WebGL context creation, canvas management, and resource disposal to prevent memory leaks and context loss.

Responsive Scaling: Uses device pixel ratio awareness with efficient canvas resizing to maintain crisp visuals across different screen densities.

Common gotchas

WebGL Context: Component requires WebGL-enabled browser. Gracefully handles context creation failures but won't render without WebGL support.

Color Range: Color values should be in 0-1 range (not 0-255). Values outside this range may cause unexpected shader behavior or clamping.

Animation Performance: Continuous shader execution can impact battery life on mobile devices. Consider pausing animation when component is not visible.

Container Sizing: Component fills its container completely. Ensure parent element has defined dimensions for proper iridescent pattern rendering.

Mouse Coordinates: Uses normalized UV coordinates for consistent behavior across different container sizes and device pixel ratios.

Speed Limits: Very high speed values (>5) may cause temporal aliasing or stuttering. Keep speed values reasonable for smooth animation.

You might also like

Questions developers actually ask