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.
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 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).
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.
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.
- 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.