Skip to main content

Installation

Install the React package from npm:
Pin your dependency version — breaking changes may ship under 0.0.x versioning.

Basic Usage

Paper Shaders provides React components for each shader effect. Import and use them as standard React components:

Available Components

All shader components follow the same pattern. Here are the available shaders:
  • MeshGradient - Flowing interplay of color spots with organic distortion
  • StaticMeshGradient - Multi-point mesh gradients (static)
  • StaticRadialGradient - Radial gradients with focal point control
  • GrainGradient - Multi-color gradients with grainy textures
  • DotOrbit - Animated multi-color dots orbiting in cells
  • DotGrid - Static grid of circles, diamonds, squares, or triangles
  • Voronoi - Animated Voronoi pattern with customizable edges
  • Waves - Static line patterns from zigzags to smooth waves
  • SimplexNoise - Smooth animated curves with multi-color gradients
  • PerlinNoise - Animated 3D Perlin noise
  • NeuroNoise - Glowing web-like structure of fluid lines
  • Metaballs - Up to 20 gooey blobs merging into organic shapes
  • SmokeRing - Radial gradient shaped with layered noise
  • Swirl - Animated bands of color twisting into spirals
  • Spiral - Animated spiral morphing across shapes
  • Warp - Color fields warped by noise and swirls
  • GodRays - Rays of light radiating from center
  • PulsingBorder - Luminous trails forming a glowing frame
  • ColorPanels - Glowing 3D panels rotating around axis
  • Water - Water-like surface distortion with caustics
  • FlutedGlass - Streaked, ribbed glass distortions
  • ImageDithering - Dithering with multiple color palettes
  • Heatmap - Glowing gradient wave across images
  • LiquidMetal - Futuristic liquid metal material
  • HalftoneDots - Halftone-dot filter with custom grids
  • HalftoneCmyk - Classic CMYK halftone algorithm
  • PaperTexture - Realistic paper and cardboard surfaces
  • Dithering - 2-color dithering over various patterns

Component Props

Each shader component accepts specific parameters plus common props:

Common Props

All shader components support these props:

Shader-Specific Props

Each shader has its own parameters. For example, MeshGradient:
Check the API reference for each shader’s specific parameters.

Using Presets

Each shader includes preset configurations you can import and use:
Available presets are exported with each shader:
  • meshGradientPresets
  • smokeRingPresets
  • dotOrbitPresets
  • waterPresets
  • And more…

Animation Control

Control animation with the speed and frame props:
When speed={0}, the shader pauses and requestAnimationFrame stops, eliminating performance costs for static shaders.

Color Formats

Colors can be specified in multiple formats:

Image Shaders

Some shaders accept images as filters. Pass image URLs or HTMLImageElement:
Images must be fully loaded before the shader renders. The React package automatically handles image loading, but ensure CORS is configured for external images.

Refs and Imperative API

Access the underlying shader instance via ref:

Server-Side Rendering

Paper Shaders are marked with 'use client' and handle SSR gracefully:
The shader canvas won’t render during SSR but will mount on the client. The component reserves space so layout doesn’t shift.
Pass undefined for optional props during SSR - they’ll be safely ignored until client hydration.

Performance Optimization

Using memo

All shader components are wrapped in React.memo with smart equality checks:

Stable References

Use stable color arrays to prevent unnecessary updates:

Resolution Control

See the Performance Guide for details on minPixelRatio and maxPixelCount.

TypeScript Support

Full TypeScript support with exported types:

Troubleshooting

Shader not rendering

1

Check WebGL support

Paper Shaders requires WebGL 2. Check browser compatibility.
2

Ensure container has size

The shader matches its container size. Use style={{ width, height }} or CSS to size the container.
3

Verify images are loaded

For image shaders, ensure images are accessible and CORS-enabled.

Performance issues

  • Reduce maxPixelCount for lower-powered devices
  • Set speed={0} for static shaders
  • Use minPixelRatio={1} on low-end devices
  • See Performance Guide for detailed optimization

Colors not appearing correctly

  • Verify color format (hex, rgb, hsl, or array)
  • Check alpha channel - colors with alpha=0 are invisible
  • Ensure color array has at least 2 colors for gradients

Next Steps

Vanilla Usage

Learn how to use Paper Shaders without React

Customization

Deep dive into customizing shader parameters

Sizing & Fit

Control shader sizing and responsive behavior

Performance

Optimize shaders for production