canvas-ui README

The project's README from github.com/DavidHDev/canvas-ui. As one markdown file: README.md.

Canvas UI

An open source library of creative, framework-agnostic components drawn on canvas.
Fluid simulations, shader effects, and 3D scenes, running over your live, fully interactive interface or drawn entirely on their own. WebGL or WebGPU via vgpu, your choice.

canvasui.dev · Docs · Components · Playground · Installation · Rendering

GitHub stars 38 components License: MIT + Commons Clause

React Vue Svelte Solid Preact TypeScript

What makes it different

Effects come in two categories:

🎨 38 components and counting: Liquid, Glass, Shatter, Force Field, Chrome Object, and more
🧩 Framework agnostic: every component ships for React, Solid, Preact, Vue, Svelte, and vanilla, in both WebGL and WebGPU builds
🖥️ Two renderers: WebGL with GLSL, or WebGPU through vgpu with WGSL
📋 Copy, do not install: source lands in your repo via a shadcn-compatible registry
⚡ Zero config: self-contained, with sensible defaults and typed props
🤖 MCP ready: let your AI assistant find and install components for you

Quick start

Add a component with the shadcn CLI (run npx shadcn@latest init first if you have not):

npx shadcn@latest add @canvas-ui/liquid-react

Swap liquid for any component, react for solid, preact, vue, svelte, or vanilla. Source lands in components/canvasui/, yours to edit.

import { Liquid } from "@/components/canvasui/Liquid";

export default function Page() {
  return (
    <Liquid>
      <YourEntirePage />
    </Liquid>
  );
}

Live HTML components wrap your content. The subtree stays live and interactive; the effect runs on top. Universal components draw their own scene, so there is nothing to wrap. The object renderers, for example, take a src:

<ChromeObject src="/logo.svg" className="h-96" />

See the installation guide for manual setup.

WebGL and WebGPU

Every effect ships in two renderer builds. The WebGL build is the default: raw WebGL2 and GLSL, zero dependencies except three for the object effects. The WebGPU build renders through vgpu with WGSL shaders, keeps the same props and public API, and installs with the -webgpu registry suffix:

npx shadcn@latest add @canvas-ui/liquid-react-webgpu

WebGPU builds ship for all six frameworks. They need a browser with WebGPU, Chrome/Edge 113+, Safari 26+ / iOS 26, or Firefox 141+. If WebGPU is missing, the wrapped content renders unchanged. Details in the rendering guide.

Components

Every component ships for all six frameworks in both renderer builds. Compare them in the playground.

Live HTML

These draw your real, interactive HTML into the canvas. The full effect needs HTML-in-canvas (Chrome 157 and later); other browsers get a working fallback.

🌊 Fluid & motion
Component What it does Component What it does
Liquid Pointer-driven fluid simulation Ripple Water ripples from every click
Cloth Fabric you can grab, fold and fling Droplets Rain running down the screen
Bubble Metaball droplet trailing the cursor Displacement Grid that ripples away from the cursor
🔥 Fire & energy
Component What it does Component What it does
Blaze Firelight, smoke, embers, heat haze Flame Wrap Border of fire around any element
Force Field Shield framing the page, shockwaves Laser Beam that reveals content on scroll
💎 Glass & optics
Component What it does Component What it does
Glass Crystal-ball lens that follows the cursor Frost Ice that melts under the cursor and refreezes
Magnify Sci-fi scanner lens with a HUD reticle Bend Folds the page like the face of a cube
Peel Peels back to reveal a second layer Clouds Mist parted by cursor wind
📼 Retro & glitch
Component What it does Component What it does
VHS Worn tape wave, chroma bleed, and grain Glitch Broadcast tearing with RGB splits
Retro Dither Dither lens that pixelates the page Decrypt Reveal Cipher text decrypting at the cursor
Glyph Rain Falling glyphs that light up the page
✨ Particles & structure
Component What it does Component What it does
Particle Reveal Particles merging into crisp UI Particle Scroll Sand that reassembles on scroll
Shatter 3D glass shards that lift and refract Grid 3D tiles rippling around the cursor
Hex Float Floating hex tiles with cursor lift ASCII Sweep Glowing ASCII band that swaps panels
Particle Select Menu of pixels, dither or ASCII Heatmap Reveal Loading heatmap that burns away

Universal

These draw their whole scene on the GPU, with no HTML-in-canvas needed, so they look the same in every modern browser. Cursor effects, surfaces and object renderers are the first groups, with more kinds of Universal effects on the way.

🖱️ Cursor effects

Drop them over any page, or wrap one section.

Component What it does
Asciify Soft ASCII trail that drifts and ripples on click
🧵 Surfaces

Lay them over a page, put them behind content, or print an image or the page onto them.

Component What it does
Canvas Canvas, linen, paper and parchment, built on Paper Shaders
🧊 Object renderers

Point any of them at a GLB/glTF model, SVG, or image.

Component What it does Component What it does
Glass Object Solid glass with real dispersion Chrome Object Liquid chrome with flowing reflections
Liquid Object Dragged through swirling liquid Particle Object Particles that scatter and spring back
ASCII Object Redrawn as shape-matched ASCII Dithered Object Rendered through a 1-bit dither
Ink Object Printed in rough ink strokes Wireframe Object Edge lines with hidden-line removal
Topographic Object Contour lines like a survey map

Browser support

Browser Live HTML Universal
Chrome 157 and later ✅ Full effect ✅ Full effect
Everything else ⚠️ Fallback: GPU overlay or plain HTML ✅ Full effect

HTML-in-Canvas ships in Chrome 157. Older Chrome versions can turn it on with the chrome://flags/#canvas-draw-element flag, or with an origin trial token on your site. Android stays on the fallback for now. Details in the docs.

Chrome 150 and 155 changed the WebGL and WebGPU entry points: texElementImage2D() became texElementSubImage2D(), and copyElementImageToTexture() became drawElementImageToTexture(). Neither change requires a migration in Canvas UI. The HTML effects capture content with the 2D drawElementImage() API, then upload the canvas with standard texImage2D() (WebGL) or copyExternalImageToTexture() (WebGPU). Those upload methods keep their existing signatures. This also applies to the generated registry components for all six frameworks.

The same updates changed capture markup and hit testing. Canvas UI uses content="drawable" and drawable when the browser supports them and falls back to layoutsubtree on older versions. When drawElementImage() returns a transform (Chrome 154 to 156), Canvas UI forwards it to updateElementGeometry(); newer versions sync hit testing on their own. Either way, scrolling, clicks, and cursor effects keep working.

Both renderers follow pinch zoom through visualViewport, increasing capture and rendering resolution while preserving the HTML's position and interactions. The normal 2× device-pixel-ratio budget is multiplied by the zoom scale, subject to GPU limits, an 8192-pixel maximum dimension, and a 16-megapixel buffer budget. Particle Scroll uses plain HTML without a GPU overlay when HTML-in-Canvas is unavailable, including in Safari.

Use with AI

The registry is MCP ready, so your assistant can browse and install components:

npx shadcn@latest mcp init --client claude

Works with Claude Code, Cursor, VS Code, Codex, and OpenCode. Then just ask: "add the Liquid component from Canvas UI".

Development

This repo holds the library source, the docs site (Next.js 16, Tailwind v4, on Cloudflare Workers), and the registry build.

npm install
npm run dev        # builds the registry, then starts next dev
npm run build      # production build
npm run deploy     # build and deploy to Cloudflare
Path What lives here
src/lib/<Component>/ WebGL and WebGPU engines plus framework wrappers
src/demos/ Interactive demo and controls for each component
src/app/ Documentation site routes
scripts/build-registry.mts Generates public/r/*.json for the shadcn CLI

Each component is plain TypeScript with thin framework wrappers. WebGL builds use raw WebGL2 and GLSL. WebGPU builds use vgpu and WGSL. Nothing depends on another Canvas UI component, and each engine defines its own props.

Contributing

Issues and pull requests welcome. See CONTRIBUTING.md.

License

MIT + Commons Clause. Free in your own projects, commercial or not. The Commons Clause only restricts selling the library itself.


Built by David Haz · @davidhaz

canvasui.dev

canvas-ui (DavidHDev/canvas-ui)

Searching Database…

What is this?Canvas UI is an open-source library of creative canvas components for building live, interactive web effects. Each component draws fluid simulations, shader effects, or 3D scenes directly over your real, still-clickable HTML.
Do I install this as an npm package, or copy the source into my project?Neither in the usual sense - components are copied into your own repo through a shadcn-compatible registry, so the source lands directly in your codebase (components/canvasui/) for you to edit, not as a hidden dependency.
How do I add a component to my project?Run 'npx shadcn@latest init' if you haven't set up shadcn yet, then use the shadcn CLI to add a specific component, swapping in the component name and your framework (react, solid, preact, vue, svelte, or vanilla).
Which frameworks does it support?Every component ships for six frameworks - React, Solid, Preact, Vue, Svelte, and vanilla JS - in both WebGL and WebGPU builds.
Does the live HTML-in-canvas effect work in every browser?No - the full HTML-in-canvas effect, which redraws and distorts your real DOM, currently needs Chrome with the canvas-draw-element flag or an origin trial token. Everywhere else, components fall back to a GPU overlay so the page still works, while the separate 3D object effects render everywhere with no flag at all.
Can I use this commercially without restriction?Mostly yes - it's MIT plus the Commons Clause, so it's free in your own projects whether commercial or not. The Commons Clause only stops you from reselling Canvas UI itself as a product.
What's the difference between the WebGL and WebGPU builds?The WebGL build is the default renderer, using raw WebGL2 and GLSL with no dependencies besides three for 3D effects. The WebGPU build renders through a library called vgpu with WGSL shaders, keeps the same props and API, and needs a WebGPU-capable browser like Chrome/Edge 113+, Safari 26+, or Firefox 141+.
How many components are there and what kinds of effects do they cover?There are 35 components grouped into categories like fluid and motion (Liquid, Ripple, Cloth), fire and energy (Blaze, Force Field, Laser), glass and optics (Glass, Frost, Magnify), retro and glitch (VHS, Glitch, Asciify), particles and structure (Shatter, Particle Reveal), plus 3D object effects that render any GLB/glTF model, SVG, or image.
Can my AI coding assistant install these components for me?Yes - the component registry is MCP-ready, so assistants like Claude Code, Cursor, VS Code, Codex, and OpenCode can browse and install a component just by being asked, e.g. 'add the Liquid component from Canvas UI'.
Do the 3D object effects also need the special Chrome flag?No - 3D effect components like Shatter, Particle Object, or Glass Object work in every browser with no flag needed, unlike the HTML-in-canvas components which require Chrome's canvas-draw-element flag or fall back to a GPU overlay.
Creator
DavidHDev
Size
16.1 MB
Stars
5.5K
Updated
CommitNov 08
Age
4mo
Commits · 90 Days