React Sparks Drifting Shaders
Realistic fire simulation with drifting sparks and procedural noise. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.
Building fire and spark effects?
Join our Discord community for help from other developers working with WebGL shaders.
Look, we've all tried to build realistic fire effects. You either end up with basic particle systems that look nothing like proper flames or JavaScript calculations that can't handle complex fire simulation smoothly. This React component uses advanced WebGL shaders with simplex noise and procedural spark generation that actually runs at 60fps without melting your CPU.
Smooth sparks drifting animation
Mesmerizing fire simulation with realistic drifting sparks that won't destroy your performance metrics:
Created by Sjeiti in 2017-01-17
Built for React applications with TypeScript and Next.js in mind. The animation runs entirely on the GPU using WebGL shaders with Ashima Arts' simplex noise and procedural particle systems. Works seamlessly with shadcn/ui design systems.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/sparks-drifting-shaders.json
npx shadcn@latest add https://www.shadcn.io/registry/sparks-drifting-shaders.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/sparks-drifting-shaders.json
bunx shadcn@latest add https://www.shadcn.io/registry/sparks-drifting-shaders.json
Usage
import { SparksDriftingShaders } from "@/components/ui/sparks-drifting-shaders";
export default function Hero() {
return (
<SparksDriftingShaders>
<div className="relative z-10">
<h1>Your content here</h1>
</div>
</SparksDriftingShaders>
);
}
Why most fire implementations suck
Most developers try to animate fire with CSS animations or basic particle systems. Bad idea. You're dealing with unrealistic flame behavior, poor spark physics, and wondering why your React app feels sluggish. Some use canvas drawing with JavaScript fire simulation, which sounds smart until you realize you're computing flame dynamics for every pixel on every frame.
This React component uses mathematical simplex noise with procedural spark generation and realistic fire physics. The GPU handles everything using optimized noise functions with authentic flame behavior simulation. No JavaScript calculations, no particle system overhead, just smooth 60fps mathematical fire effects.
Features
- Zero JavaScript animation overhead - Pure WebGL fire simulation runs on GPU
- Simplex noise generation with MIT-licensed Ashima Arts implementation
- Procedural spark particles with realistic physics and lifecycle management
- TypeScript definitions for proper IDE support in React projects
- Customizable parameters with 4 props for complete control
- Performance optimization through efficient noise functions
- shadcn/ui compatible for consistent design systems
- Responsive design with automatic canvas resizing
API Reference
SparksDriftingShaders
Main container component for the sparks drifting effect.
Prop | Type | Default | Description |
---|---|---|---|
speed | number | 1.0 | Animation speed multiplier (0.1 to 3.0) |
sparkSize | number | 1.0 | Size of individual sparks (0.5 to 2.0) |
fireIntensity | number | 1.0 | Fire brightness and intensity (0.1 to 2.0) |
smokeIntensity | number | 1.0 | Smoke opacity and density (0.1 to 2.0) |
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 noise calculations. Consider reducing speed and intensity props for better performance.
Fire appears too bright: Lower the fireIntensity
prop. Values around 0.7-0.8 work well for subtle background effects without overwhelming content.
Sparks too small/large: Adjust the sparkSize
prop. Lower values (0.5-0.7) create subtle sparks, higher values (1.5-2.0) create more prominent spark effects.
Smoke too heavy: Lower the smokeIntensity
prop for lighter smoke effects. Values around 0.5-0.7 work well for atmospheric effects.
You might also like
Explore other shader-based background components for React applications:
Fire Shaders
Realistic fire effects with organic flame movement
Biomine Shaders
Organic biomine tunnel with gyroid surfaces
Plasma Shaders
Organic plasma effects with fluid WebGL animations
Nebula Shaders
Cosmic nebula patterns with deep space aesthetics
Aurora Shaders
Northern lights effects with realistic color gradients
Cosmic Waves Shaders
Ethereal wave patterns with cosmic color palettes
Questions developers actually ask
React Soap Bubbles 2D Shaders
Realistic soap bubble simulation with procedural noise and cellular patterns. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.
React Sphere Field Shaders
3D sphere field raymarching with spherical projection and organic distortion. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.