Fills its parent with a fragment shader or a cloud of points. Theme colors, pointer and progress arrive as uniforms; it pauses off screen, lowers its resolution when slow, and holds still under reduced motion.
Installation
Once per project: add the Pro registry and your licence key.
components.json{ "registries": { "@ballmac": "https://ui.ballmac.com/r/{name}.json", "@ballmac-pro": { "url": "https://ui.ballmac.com/r/pro/{name}.json", "headers": { "Authorization": "Bearer ${BALLMAC_LICENSE_KEY}" } } } }.env.localBALLMAC_LICENSE_KEY=your-licence-keyAdd it.
$ pnpm dlx shadcn@latest add @ballmac-pro/webgl-canvasNeed a licence or help with setup?
Usage
import { WebglCanvas } from "@/components/ballmac/webgl-canvas"The full example is in the Code tab above.
API reference
| Prop | Type | Default |
|---|---|---|
fragment*GLSL ES 3.00 fragment shader body (no version line). It can read `uResolution`, `uTime`, `uPointer`, `uPointerDown`, `uProgress` and the uniforms below. | string | — |
vertexVertex shader body, for a cloud of `points` placed from `gl_VertexID`. Leave out for a full-screen shader. | string | — |
pointsHow many points to draw. Needs `vertex`. | number | — |
blendHow points blend: "add" glows on a dark ground, "alpha" is ordinary transparency. | "add" | "alpha" | — |
colorsTheme colors the shader reads, as `{ uniformName: "--css-variable" }`. Each becomes a `vec3` and follows light and dark. | Record<string, string> | — |
uniformsYour own uniforms, applied once and whenever this prop changes. | Uniforms | — |
onFrameCalled every frame, before drawing, to return uniforms that change continuously (scroll position, momentum). | (frame: FrameInfo) => Uniforms | void | — |
progressA value from 0 to 1 the shader reads as `uProgress`, for example scroll progress. | number | 0 |
maxDprHighest device pixel ratio to render at. Heavy shaders do well at 1.5. | number | 1.5 |
minScaleLowest share of that resolution the adaptive quality may fall to when frames run slow. | number | 0.5 |
pausedStops the scene, for example while a dialog is open. | boolean | false |
stillTimeThe moment, in seconds, that is drawn once when the visitor prefers reduced motion. | number | 4 |
labelDescribes the picture for assistive technology. Leave empty when the scene is only decoration. | string | — |
fallbackShown instead of the scene when the browser or device cannot run WebGL. | React.ReactNode | — |
Also accepts the standard attributes of its root element.
Use with AI
Place <WebglCanvas fragment={glsl} colors={{ uAccent: '--primary' }} /> inside a relative container; write the picture as a GLSL ES 3.00 fragment shader reading uTime, uPointer, uProgress and your colors. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI WebGL Canvas (@ballmac-pro/webgl-canvas) to this project with the shadcn MCP, then use it where it fits.
Use it for
- A shader-drawn hero, background or product stage
- Effects that must follow the theme tokens and stay still for people who ask for less motion
Not for
- Soft CSS gradients and glows (aurora-background is lighter)
- Many canvases on one page (each runs its own loop)
Registry JSON (needs your licence key): https://ui.ballmac.com/r/pro/webgl-canvas.json
Credits
Covered by the Ballmac UI Pro license.
- npm
- None
Pairs well with
Cover Art
Cover pictures drawn from a seed in your theme's chart colors: color fields, rings, bars, dots or waves. The same seed always draws the same picture, so an item without an image still looks finished.
Globe
An interactive WebGL dot globe (cobe) with markers, drag-to-spin momentum and arrow-key control. Colors come from theme tokens and repaint on theme change; starts lazily and pauses off-screen.
Grid Pattern
A crisp square-grid background in the border color with optional dashed lines, filled cells, softly lighting random cells and an edge fade, drawn as one SVG pattern.
Aurora Background
Soft, slowly drifting aurora light made of blurred token-colored glows with fine vertical curtains and an optional radial fade. Pure CSS layers, paused off-screen, still under reduced motion.