Skip to content

Mesh Gradient

Add a slowly shifting, theme-aware gradient behind a hero section.

import { MeshGradient } from '@youj/motion/backgrounds'

Experimental: what this label means

Installation & usage

npm i @youj/motion

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use it for a hero, a launch page or a sign-up screen that should feel warm and premium without saying anything specific. It's color without line work, so it sits behind a headline more calmly than any other background. Don't use it behind long text or tables, and give it one section per page: a second gradient dilutes the first.

The gradient fills its nearest positioned ancestor and paints behind your content, so make the container relative and isolate.

import { MeshGradient } from '@youj/motion/backgrounds'

export function Hero() {
  return (
    <section className="relative isolate min-h-[640px]">
      <MeshGradient />
      <h1 className="relative">The workspace that moves as fast as you think</h1>
    </section>
  )
}

Reference

Propscolors, intensity, speed… (6)

Props

MeshGradient props
PropType
colorsstring[]

Up to four CSS colors for the color masses. Default: an analogous family derived from the accent token.

–
intensitynumber

How much of the field is colored vs. canvas. 0–1.5, default 1.

default 1

1
speednumber

Drift speed multiplier.

default 1

1
grainnumber

Film grain amount, 0–1. Dithering against banding is always on.

default 0.5

0.5
interactiveboolean

The field leans toward the pointer.

default true

true
classNamestring–
PerformanceIt's one WebGL2 fragment shader on a single full-screen triangle,…

Performance

It's one WebGL2 fragment shader on a single full-screen triangle, rendered at a device-pixel ratio capped at 2. The loop pauses offscreen and in hidden tabs, survives a lost GL context, and releases the context on unmount. Without WebGL2 it falls back to a static CSS gradient in the same colors.

MotionDrift, pointer lean · reduced motion

Motion

Motion tokens
MomentTokens
Driftcontinuous shader clock
no token

speed ÷ time scale

speed ÷ time scale
Pointer leaneases in and out with the pointer
no token

smoothed per frame

smoothed per frame

Reduced motion

Draws one composed still frame and stops. There's no drift and no pointer response, and the frame redraws only when the size, the props or the theme change.

Reduced motion

The gradient draws one composed frame and holds it, with the film grain halved for the still image. The colors and the composition stay the same, so the section looks as designed, only still. It redraws when the size, the props or the theme change. Switch on Reduced motion in any preview above to compare.

AccessibilityARIA

Accessibility

It's decorative, so it's aria-hidden and ignores pointer events. Check your text's contrast over the brightest part of the field. A lower intensity keeps it calm behind copy.