Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Shader gradient

An animated WebGL mesh gradient that fills its box.

Installation

pnpm add @heyramzi/ui

Usage

import { ShaderGradient } from "@heyramzi/ui/effects/shader-gradient";

Keyboard and accessibility

  • It's hidden from screen readers.
  • With reduced motion on, it draws a still frame. It also pauses offscreen and in a hidden tab.

API reference

class string
color1 string
Default "#ff5005"
Warm stop. Any CSS color, including `var(--token)`. Read at the left edge of the plane.
color2 string
Default "#dbba95"
Middle stop. Read at the right edge of the plane.
color3 string
Default "#d0bce1"
Cool stop. Mixed in by the noise displacement, so it rides the crests and troughs.
bgColor string
Default "#000000"
Painted behind the mesh. The mesh covers the frame at the default camera, so it only shows at extreme angles.
animate boolean
Default true
false freezes the field at `uTime`. Forced false when the visitor asks for reduced motion.
brightness number
Default 1.2
Ambient light. 1 is flat, above 1 lifts the whole field.
cAzimuthAngle number
Default 180
Camera azimuth in degrees.
cPolarAngle number
Default 90
Camera polar angle in degrees.
cDistance number
Default 3.6
Camera distance from the origin.
fov number
Default 45
Vertical field of view in degrees.
positionX number
Default -1.4
positionY number
Default 0
positionZ number
Default 0
rotationX number
Default 0
Mesh rotation in degrees, applied in XYZ order.
rotationY number
Default 10
rotationZ number
Default 50
uDensity number
Default 1.3
Noise density. Higher packs more folds into the same plane.
uSpeed number
Default 0.4
Noise travel speed.
uStrength number
Default 4
Displacement amplitude. Drives how far color3 pushes into the mix.
uTime number
Default 0
Starting time offset in seconds. Two instances with different offsets never sit on the same frame.
grain boolean
Default true
Halftone dot screen over the render. This is the upstream `grain` switch.
grainRadius number
Default 2
Halftone dot radius in device pixels.
pixelDensity number
Default 1
Render scale. 1 matches upstream and is enough for a gradient this smooth.
Prop Type Default
class string
color1

Warm stop. Any CSS color, including `var(--token)`. Read at the left edge of the plane.

string "#ff5005"
color2

Middle stop. Read at the right edge of the plane.

string "#dbba95"
color3

Cool stop. Mixed in by the noise displacement, so it rides the crests and troughs.

string "#d0bce1"
bgColor

Painted behind the mesh. The mesh covers the frame at the default camera, so it only shows at extreme angles.

string "#000000"
animate

false freezes the field at `uTime`. Forced false when the visitor asks for reduced motion.

boolean true
brightness

Ambient light. 1 is flat, above 1 lifts the whole field.

number 1.2
cAzimuthAngle

Camera azimuth in degrees.

number 180
cPolarAngle

Camera polar angle in degrees.

number 90
cDistance

Camera distance from the origin.

number 3.6
fov

Vertical field of view in degrees.

number 45
positionX number -1.4
positionY number 0
positionZ number 0
rotationX

Mesh rotation in degrees, applied in XYZ order.

number 0
rotationY number 10
rotationZ number 50
uDensity

Noise density. Higher packs more folds into the same plane.

number 1.3
uSpeed

Noise travel speed.

number 0.4
uStrength

Displacement amplitude. Drives how far color3 pushes into the mix.

number 4
uTime

Starting time offset in seconds. Two instances with different offsets never sit on the same frame.

number 0
grain

Halftone dot screen over the render. This is the upstream `grain` switch.

boolean true
grainRadius

Halftone dot radius in device pixels.

number 2
pixelDensity

Render scale. 1 matches upstream and is enough for a gradient this smooth.

number 1