A real-feeling, painterly flame: a hearth along the bottom, a calm candle or burning type, with licking tongues, rising sparks and heat shimmer.
- shader
- webgl
- fire
- flame
- candle
- text
- element
- interactive
Installation
pnpm dlx shadcn@latest add https://kagadmodyaa.vercel.app/r/fire.jsonNeeds a React + Tailwind project set up with shadcn. Copies the effect into your project, along with lib/effect-runtime.ts, the small WebGL layer it runs on. No other dependencies.
Or from npm
pnpm add @kagadmodyaa/effectsimport { Fire } from '@kagadmodyaa/effects/fire'One package with every free effect, one import path each. No Tailwind or shadcn needed, and no stylesheet to import: the few layout rules an effect needs come with it. The npm package and the command above ship the same source.
Usage
Use it like any other component. Choose a theme with preset; any prop you pass as well overrides the preset.
import { useRef } from 'react'
import { Fire, type FireHandle } from '@/components/effects/fire/fire'
export function Hearth() {
const fire = useRef<FireHandle>(null)
return (
<section className="relative h-[560px] overflow-hidden">
{/* fills its parent: a hearth burns along the bottom, so put your headline in the top half */}
<Fire ref={fire} preset="Hearth" className="absolute inset-0" />
<div className="relative z-10 mx-auto max-w-xl px-6 pt-20 text-center text-white">
<h1 className="text-5xl font-semibold tracking-tight">Gather round.</h1>
<button onClick={() => fire.current?.stoke()}>Stoke the fire</button>
</div>
</section>
)
}
// A calm candle as a loader or CTA accent, on any page colour:
// <div className="size-40"><Fire mode="candle" background="transparent" /></div>
// Flames rising from a word (drawn by the shader; the word is the accessible name):
// <Fire mode="text" text="Ignite" preset="Spirit" />
// Presets: Hearth, Blue Gas, Spirit, Ember Night, Paper (the light one: ink and ochre on paper, use dark text).
// The stage above is <FireShowcase />, also exported.<Fire preset="Blue Gas" mode={"hearth"} />Presets
HearthBlue GasSpiritEmber NightPaper
Props
| Name | Type | Default | Description |
|---|---|---|---|
| preset | 'Hearth' | 'Blue Gas' | 'Spirit' | 'Ember Night' | 'Paper' | none (the defaults below) | A named theme. Any prop you pass as well overrides the preset’s value. |
| mode | 'hearth' | 'candle' | 'text' | 'hearth' | A wide fire along the bottom, one calm candle flame, or flames rising from a word. |
| intensity | number | 1 | How hot and bright the fire burns. Range 0 to 2. |
| height | number | 1 | Flame height as a multiple of the mode's natural height. Range 0.2 to 1.6. |
| wind | number | 0 | Lean of the flames, to the left (negative) or right. Range -1 to 1. |
| turbulence | number | 0.75 | 0 is a smooth, steady flame; higher licks and roars. Range 0 to 1.5. |
| speed | number | 1 | Speed of the flames and sparks. 0 freezes the fire. Range 0 to 2.5. |
| coals | number | 0.6 | The bed of glowing coals under a hearth fire. Range 0 to 1. |
| embers | number | 18 | Sparks rising from the fire (a candle keeps at most two). Range 0 to 60. |
| shimmer | number | 0.5 | Heat haze wobbling the air above the flames. Range 0 to 1. |
| text | 'Ignite' | 'Kindle' | 'Blaze' | 'Warmth' | 'Ignite' | The word the flames rise from in text mode. |
| colorCore | string | '#fff3d1' | The hottest part of the flame. A hex colour. |
| colorMid | string | '#ff8a1e' | The body of the flame, and the glow it casts. A hex colour. |
| colorEdge | string | '#b3200c' | The cooler edges and tips. A hex colour. |
| colorSmoke | string | '#3b2f2b' | The smoke the tips fade into. A hex colour. |
| background | string | '#0b0706' | Page colour; a light colour paints the fire as ink and ochre (pass 'transparent' in code to sit on your page). A hex colour. |
| pointerWind | number | 0.6 | How far the pointer pushes the flames sideways. 0 ignores the pointer. Range 0 to 1. |
| grain | number | 0.25 | Film grain. Range 0 to 1. |
| className | string | — | Extra class on the root element. The effect fills its parent: give the parent a height. |
| style | CSSProperties | — | Inline style on the root element. |
Files
What the command adds to your project, and where.
components/effects/fire/fire.tsxThe component.
components/effects/fire/flame.tsxThe component.
components/effects/fire/showcase.tsxThe component.
components/effects/fire/poster.tsxThe component.
components/effects/fire/look.tsThe component.
components/effects/fire/shaders.tsThe fragment shader, as a string. Edit it to change the picture.
components/effects/fire/mask.tsThe component.
lib/effect-runtime.tsShared by every shader effect: resizing, pausing, reduced motion, context loss and the no-WebGL fallback. Installed once.
Behaviour
- The flame is one fragment shader: noise that rises and swirls (advected upward and domain-warped) eats into the shape of the emitter more and more with height, so tongues lick upward, break off and fade into smoke. Its value is the temperature, coloured by a blackbody-like ramp from the core colour through the body and edge colours, brighter the hotter it is.
- Three modes: hearth (a wide fire along the bottom, on a bed of coals), candle (one calm flame over a wick, centred; a good loader or CTA accent) and text (flames standing on a word, drawn from a mask of the word in the page font; the word is the accessible name).
- Move the pointer across the stage and the flames lean away from it (pointer wind; 0 ignores the pointer). Click anywhere on the stage, or press the button, to stoke the fire: it surges, brightens and throws a burst of sparks for a few seconds. The ref has stoke().
- Sparks are drawn analytically with short motion trails and filtered to the pixel, so they stay smooth at any size; the noise is smooth and a fine dither keeps the dark gradients free of banding. A light background (Paper) paints the fire as ink and ochre on paper instead of light, with no glow wash; background='transparent' lets the fire sit on your own page.
- It fills its parent, pauses off screen and in a background tab, lowers its resolution automatically if frames run slow, and draws one composed still frame under prefers-reduced-motion. Without WebGL, and before the first frame, you see an SVG poster of the same flame in the same colours.