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:Gradient Shaders
Gradient Shaders
MeshGradient- Flowing interplay of color spots with organic distortionStaticMeshGradient- Multi-point mesh gradients (static)StaticRadialGradient- Radial gradients with focal point controlGrainGradient- Multi-color gradients with grainy textures
Pattern Shaders
Pattern Shaders
DotOrbit- Animated multi-color dots orbiting in cellsDotGrid- Static grid of circles, diamonds, squares, or trianglesVoronoi- Animated Voronoi pattern with customizable edgesWaves- Static line patterns from zigzags to smooth waves
Noise & Particle Shaders
Noise & Particle Shaders
SimplexNoise- Smooth animated curves with multi-color gradientsPerlinNoise- Animated 3D Perlin noiseNeuroNoise- Glowing web-like structure of fluid linesMetaballs- Up to 20 gooey blobs merging into organic shapesSmokeRing- Radial gradient shaped with layered noise
Animation Shaders
Animation Shaders
Swirl- Animated bands of color twisting into spiralsSpiral- Animated spiral morphing across shapesWarp- Color fields warped by noise and swirlsGodRays- Rays of light radiating from centerPulsingBorder- Luminous trails forming a glowing frameColorPanels- Glowing 3D panels rotating around axis
Image Filter Shaders
Image Filter Shaders
Water- Water-like surface distortion with causticsFlutedGlass- Streaked, ribbed glass distortionsImageDithering- Dithering with multiple color palettesHeatmap- Glowing gradient wave across imagesLiquidMetal- Futuristic liquid metal materialHalftoneDots- Halftone-dot filter with custom gridsHalftoneCmyk- Classic CMYK halftone algorithm
Texture Shaders
Texture Shaders
PaperTexture- Realistic paper and cardboard surfacesDithering- 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:
Using Presets
Each shader includes preset configurations you can import and use:meshGradientPresetssmokeRingPresetsdotOrbitPresetswaterPresets- And more…
Animation Control
Control animation with thespeed 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: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:
Performance Optimization
Using memo
All shader components are wrapped inReact.memo with smart equality checks:
Stable References
Use stable color arrays to prevent unnecessary updates:Resolution Control
See the Performance Guide for details onminPixelRatio 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
maxPixelCountfor 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
