[Go to site: main page, start]

Gradient mesh

Pro

A mesh gradient editor. You drag colour points around a live WebGL canvas and they blend smoothly. You can add points with a double click or remove them, recolour a point or the base from a floating glass inspector, add grain, and switch on a drift animation that loops without a seam. It exports as CSS that renders the same image, or as a 2400px PNG.

Live · keyboard ready

Arrow keys move the point, Shift moves further. Plus and minus change its size. Delete removes it. Escape selects the base. Scroll on a point to resize it.

  • A settings or brand page where people pick a background for a workspace, profile, hero or card.
  • A creative tool that makes wallpapers, covers or social images and needs a soft, controllable gradient.
  • A product page that lets visitors play with the look your tool generates.
  • Use color-picker to choose one exact color.
  • Use a static CSS gradient when nobody needs to edit it.

Installation

Pro source and install commands unlock with a Pro plan.

example.tsx
import { GradientMesh } from "@/components/arc/gradient-mesh/gradient-mesh"; export function HeroBackgroundEditor() {  return (    <GradientMesh      label="Hero background"      base="#f8efe4"      points={[        { color: "#1b2150", x: 0.1, y: 0.92, spread: 0.78 },        { color: "#5b6cff", x: 0.86, y: 0.16, spread: 0.72 },        { color: "#ff5f3a", x: 0.2, y: 0.2, spread: 0.62 },        { color: "#ffb259", x: 0.6, y: 0.64, spread: 0.5 },      ]}      onChange={value => saveTheme({ heroMesh: value })}    />  );}

GradientMesh

A mesh gradient editor. Color points sit on a live WebGL canvas and blend smoothly into each other. Drag a point to move it, double click the canvas to add one, scroll on a point to change its reach, and recolor the selected point or the base from a floating glass inspector. Randomize builds a whole new design at once: a fresh color scheme, point count, layout, base and grain, which glides into place. A grain control adds film texture, the animate switch lets the mesh drift on a seamless loop, and the design exports as CSS that renders the same image, or as a 2400 pixel PNG.

PropTypeDefaultDescription
pointsMeshPoint[]Ink, Iris, Vermillion, Apricot, RoseStarting points from bottom to top, each with a hex color, x and y as fractions of the canvas (0 to 1 from the top left), and an optional spread (0.15 to 1.2) and id. The component owns them after mount. Three to six read best.
basestring"#f8efe4"Starting hex color behind every point.
paletteMeshSwatch[]Nine swatches from Vermillion to CreamSwatches offered in the inspector, each with a name and a hex color. Names are read by screen readers and name the points that use them. A custom color picker is always available.
grainnumber0.3Starting grain, 0 to 1.
animatebooleantrueStarts with the drift on. People can switch it off in the editor.
speednumber1Multiplies the drift speed; one loop takes 20 seconds at 1. 0 holds it still. Also sets the duration of the exported CSS animation.
pausedbooleanfalseHolds the drift on its current frame. Editing keeps working.
maxPointsnumber8Most points allowed, 2 to 8. A mesh always keeps at least two.
accentstring–Any CSS color for the selection ring on handles and swatches. Defaults to the accent.
hintstring"Drag a point to move it. Double click to add one."Help shown on the canvas until the first edit. Pass an empty string to hide it.
labelstring"Gradient mesh"Accessible name of the editor.
onChange(value: GradientMeshValue) => void–Called with the saved design (base, grain, animate and every point's id, name, color, x, y and spread) after each change: a drop, a key press, a color, an added or removed point, or a grain step.
onExport(format: "css" | "png", result: string | Blob) => void–Called after Copy CSS with the CSS text, or after Save PNG with the image blob. The component still copies and downloads on its own.
mode"editor" | "background""editor""background" renders only the mesh, filling its container edge to edge: no handles, inspector, hint, border or radius. It ignores the pointer, is hidden from assistive technology, and follows points, base, grain and animate live, so passing a new palette (on a theme change, say) blends it into place. Place it in a positioned container behind your content.
classNamestring–Class on the root element.
styleCSSProperties–Inline styles on the root element.
  • The root is a labelled group. The canvas is role="img" with a description that lists every color, the base and the grain, and stays current as the mesh changes.
  • Each point is a real button with aria-roledescription="draggable point", a label with its number, color, position and size, and aria-pressed for the selected point.
  • On a point, arrow keys move it by 1% (Shift 10%, Alt a quarter percent), plus and minus or the bracket keys change its size, Delete removes it and moves focus to its neighbour, and Escape selects the base. The key help is linked with aria-describedby.
  • Colors are a radiogroup named for its target (the base or the point) with roving focus: arrows, Home and End pick a color at once. The custom color input and the remove button have specific names.
  • Adding, removing, moving, resizing, copying and saving are announced in a polite live region. Copy and save also confirm in place on their buttons, including when they fail.
  • Pointer focus draws no ring; keyboard focus shows Arc's shared focus ring. Selection shows through the accent ring on the point and the swatch.
  • One requestAnimationFrame loop steps critically damped springs and writes WebGL uniforms, handle transforms and the reach ellipse directly; React renders only when the saved design changes.
  • A held point follows the pointer on a stiff spring and lets go of the drift; on release the drift eases back in over about a second. Keyboard nudges glide on a softer spring, new points bloom from nothing and removed ones shrink away, and a new color blends in rather than switching.
  • The drift is a Lissajous loop per point with integer frequencies, so it repeats without a seam; every point also breathes its size slightly. The drift amount itself eases on and off with the switch.
  • The loop stops offscreen, in background tabs, and whenever nothing moves with the drift off or paused.
  • With reduced motion the drift switch is off and disabled, the mesh is still and every edit lands at once; all editing and exporting still work.
  • The canvas keeps a 16:9 ratio on wide containers and becomes square below 640 pixels of container width; positions are fractions, so the design survives the change.
  • The inspector floats as a glass bar over the canvas when there is room and docks under it on narrow containers, with the swatches on their own row.
  • Handles have a 44 pixel hit area and are clamped inside the canvas even when their point sits on an edge. Touches outside a handle still scroll the page.
  • The mesh is one fragment shader over a full screen triangle, up to eight points, at no more than twice the device pixel ratio.
  • Idle frames write nothing: the loop stops when springs settle and the drift is off, and DOM writes are skipped when a value has not changed.
  • The loop never reads layout; the canvas size is cached by a ResizeObserver and pointer math reads the canvas rectangle once per drag.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Use it where someone designs a background: a theme or brand settings page, a hero or cover editor, a slide or social card maker, or a wallpaper generator.
  • The exported CSS is the same model the canvas draws: a base color plus one elliptical radial gradient per point with a smoothstep falloff, so it matches the editor. Grain is an SVG noise layer blended with overlay and reads slightly softer than on the canvas.
  • With animate on, the CSS registers custom properties with @property and adds a keyframed drift that respects prefers-reduced-motion.
  • Colors are hex. Points paint in order, so later points sit on top. Point positions are fractions of the canvas, so the design scales to any aspect ratio.
  • Save PNG needs WebGL; without it the canvas falls back to live CSS and the button is disabled.

The full library index for assistants is at /llms.txt.