Gradient Grain

Pro

Light leaks on film: saturated colour that burns to white under fine grain.

backgroundgradientgrainnoisewebglshaderherofull bleed
Gradient Grain component preview

Overview

Gradient Grain is a React and Tailwind CSS grainy gradient background that looks like light leaking onto film, in Next.js or any React app, drawn in one WebGL pass. Saturated color blooms out of black and burns to white where it is hottest, in mesh, horizon, orbit, or ribbon compositions. Grain can sit still like print or move at 24 fps like film, and the light leans toward the pointer. Drawing stops when it scrolls away or the tab hides, and reduced motion leaves one frame. Use a near black background, since the light screens over it.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add gradient-grain

Usage

Import GradientGrain from @/components/wensity/gradient-grain and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { GradientGrain } from "@/components/wensity/gradient-grain";
export default function Hero() {
return (
<GradientGrain
className="h-[560px] w-full"
variant="horizon"
colors={["#2f0bff", "#4a1dff"]}
background="#020108"
>
<div className="grid h-full place-items-center text-5xl font-semibold text-white">
Light, leaking.
</div>
</GradientGrain>
);
}

Props

PropTypeDefaultDescription
variant"mesh" | "horizon" | "orbit" | "ribbon""mesh"Composition of the light: leaks that cross and burn out low, a glow from the lower corner, a turning ring, or a flowing band.
colorsstring[]AfterglowColours of the light, 1 to 5 hex values. Saturated hues work best: where they meet, they burn to white.
exposurenumber1.6How hot the light burns. Higher values blow the cores out to white.
backgroundstring"#030304"Page colour the light sits on. The light screens over it, so near-black reads best.
grainnumber0.55Grain strength, 0 to 1.
grainSizenumber1.25Size of one grain in CSS pixels. 1 is fine film, 3 and up is coarse riso.
grainMotionbooleanfalseLet the grain move like film at 24 fps instead of sitting still like print.
speednumber1Motion speed of the light. 0 holds it still until the pointer moves.
pullnumber0.5How far the light leans toward the pointer. 0 turns it off.
dprnumber-Render scale. Defaults to the device ratio, capped at 2.
pausedbooleanfalseFreeze on the current frame.
childrenReactNode-Content layered above the gradient, such as hero copy.

Featured in React 3D components.