Skip to content
TrademarkTrademark
Docs
Effects

GradientFx

Updated: November 25, 2026
View on GitHub

GradientFx draws a field of soft colour bands that bend and flow through each other under a fine film grain, the look of a blurred mesh gradient behind a hero. It is one small shader, capped at 30 frames a second, that sleeps while it is off screen or in a hidden tab. Children sit on top of it, so the field is the section itself rather than a layer you position. It ships in @once-ui-system/fx from 3.1.

With no colors, the field runs from the page background through your brand to your accent, so it follows the theme, the scheme and any StyleScope around it, and redraws when the theme changes.

Colours

colors is a ramp from shadow to highlight, two to six stops. The first stop is the ground the bands rest on. Each stop can be a token (brand-solid-strong, accent-weak, page-background), a custom property (--my-color) or any CSS colour.

Blur and grain

blur sets how soft the bands are, from crisp ribbons at 0 to a haze at 1 (default 0.6). grain sets the film grain, from clean at 0 to heavy at 1 (default 0.35).

Direction, speed and seed

angle turns the bands, in degrees: 0 runs them left to right and a positive angle turns them clockwise (default -30). speed scales the drift, as a number or "slow", "medium" and "fast" (0.5, 1 and 2). seed picks the field: the same seed draws the same field on every visit and on the server, so a page doesn't change between renders.

As a hero

GradientFx is a Flex, so it takes layout props and lays out its children like a Column or Row. A dark palette reads the same in both themes; wrap it in a StyleScope with config={{ theme: "dark" }} so the text on it is set for a dark ground.

How it works

  • One shader. A single fragment shader draws the bands from layered noise, warps them so they bend, and adds a fresh grain each frame with a little dither against banding.
  • Cheap to keep on screen. It renders at most 30 frames a second, pauses when it scrolls out of view or the tab is hidden, and resumes where it left off.
  • Reduced motion. With reducedMotion="auto" (the default) it follows the visitor's setting and holds a still frame. true always holds still; false always moves.
  • Server and no WebGL. On the server, and in a browser without WebGL, it draws blurred CSS blobs from the same seed and colours, so the first paint already looks right and the shader fades in over it.
  • Decoration only. The field is hidden from assistive technology; only its children are read.

API reference

Type
Default
colors
The ramp, shadow to highlight, 2 to 6 stops: tokens, custom properties or CSS colours. The first is the ground. Default: page background, brand, accent.
string[]—
speed
A multiplier on the drift (1), or "slow", "medium", "fast" (0.5, 1, 2).
numbermediumslowfast
—
grain
Film grain, 0 (clean) to 1 (heavy). Default 0.35.
number0.35
blur
How soft the bands are, 0 (crisp ribbons) to 1 (a haze). Default 0.6.
number0.6
angle
Degrees the bands run along; 0 is left to right, positive turns them clockwise. Default -30.
number-30
seed
Picks the field. The same seed draws the same field, on the server too.
number0
reducedMotion
"auto" follows the visitor's setting; true holds a still frame; false always moves.
booleanauto
auto
children
React.ReactNode—
…and every FlexProps propinherited—
Edit this page on GitHub