Skip to content
DavidHDevPublic

About

A library of creative canvas components. Real HTML with WebGL effects running over it. React, Vue, Svelte, vanilla.

Topics

Resources

Contributing

Stars

5.5k stars

Watchers

17 watching

Forks

Repository files navigation

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:

  • Live HTML effects use the HTML-in-canvas API, on by default in Chrome 157, to draw your real DOM into the canvas. Text stays selectable, links stay clickable, and the page becomes a texture that fire, fluid, and glass distort in real time. Where the API is missing, they fall back to a GPU overlay or plain HTML, so every visitor gets a working page.
  • Universal effects draw their whole scene on the GPU instead of capturing the page, so they look and behave the same in every modern browser.
🎨 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 rippling in the wind 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 Sparks, smoke, and heat distortion Flame Wrap Border of fire around any element
Force Field Energy shield with click 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 Asciify ASCII lens that follows the cursor
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 Canvas Woven canvas you drag wet paint across
ASCII Sweep Glowing ASCII band that swaps panels

Universal

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

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

About

A library of creative canvas components. Real HTML with WebGL effects running over it. React, Vue, Svelte, vanilla.

Topics

Resources

Contributing

Stars

5.5k stars

Watchers

17 watching

Forks

Contributors

Languages