Backgrounds

Grainient

An animated grainy mesh-gradient rendered on a WebGL2 shader.

Adapted from React Bits

Install

bun add ogl

Then copy 2 files into your project:

  • components/registry/grainient/grainient.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
timeSpeednumber1Overall animation speed.
warpStrengthnumber0.8Domain-warp intensity.
warpFrequencynumber2Warp detail frequency.
blendSoftnessnumber0.5Softness of the gradient blend.
noiseScalenumber1.2Scale of the underlying noise.
grainAmountnumber0.12Film-grain intensity.
contrastnumber1Output contrast.
saturationnumber1.1Output saturation.
zoomnumber1Camera zoom.
color1string (hex)"#f754f1"First gradient color.
color2string (hex)"#6d28d9"Second gradient color.
color3string (hex)"#22d3ee"Third gradient color.

What It Demonstrates

Loop
An animation that repeats, a set number of times or infinitely.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Compositing
Letting the GPU move or fade an element on its own layer without redoing layout or paint.

Related Components

Appears In