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 that run over your live, fully interactive interface. WebGL or WebGPU via vgpu, your choice.

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

GitHub stars CI status 35 components License: MIT + Commons Clause

React Vue Svelte Solid Preact TypeScript

What makes it different

Most components use the experimental HTML-in-canvas API to read and redraw your live DOM. Text stays selectable, links stay clickable, and the page becomes a texture that fire, fluid, and glass distort in real time.

Where it is not supported, components fall back to GPU overlays, so every visitor gets a working page.

🎨 35 components and counting: Liquid, Glass, Shatter, Force Field, Decrypt Reveal, 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>
  );
}

Most components wrap your content. The subtree stays live and interactive; the effect runs on top.

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.

🌊 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
🧊 3D effects: no flag needed, these work everywhere

Point these at a GLB/glTF model, SVG, or image to render it as a 3D scene.

Component What it does Component What it does
ASCII Object Redrawn as shape-matched ASCII Glass Object Liquid glass with real dispersion
Particle Object Particles that scatter and spring back Dithered Object Rendered through a 1-bit dither
Liquid Object Dragged through swirling liquid

Browser support

Browser HTML-in-canvas components 3D effect components
Chrome with the flag or origin trial ✅ Full effect ✅ Full effect
Everything else ⚠️ GPU overlay fallback ✅ Full effect

Html-in-canvas needs Chrome with the chrome://flags/#canvas-draw-element flag. An origin trial token lifts that for your visitors. That is how canvasui.dev runs in a plain Chrome install. Details in the docs.

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…

这是什么?Canvas UI 是一个开源的创意画布组件库,用于构建生动的交互式网页效果。每个组件直接在你的真实、仍可点击的 HTML 上绘制流体模拟、着色器效果或 3D 场景。
我是把它作为 npm 包安装,还是把源码复制进项目?按通常意义来说两者都不是——组件通过兼容 shadcn 的注册表复制到你自己的仓库,源码直接进入你的代码库(components/canvasui/)供你编辑,而不是作为隐藏依赖。
怎么把组件加到我的项目里?如果还没设置过 shadcn,先运行 'npx shadcn@latest init',然后用 shadcn CLI 添加具体组件,替换为组件名和你的框架(react、solid、preact、vue、svelte 或 vanilla)。
它支持哪些框架?每个组件都为六个框架发布——React、Solid、Preact、Vue、Svelte 和原生 JS——同时提供 WebGL 和 WebGPU 两种构建。
HTML 上屏的实时效果在所有浏览器里都能用吗?不是——完整的 HTML 上屏(HTML-in-canvas)效果会重绘并扭曲你的真实 DOM,目前需要开启 canvas-draw-element 标志的 Chrome 或 origin trial 令牌。在其他环境中,组件会回退到 GPU 覆盖层以保证页面正常工作;而独立的 3D 物体效果在任何浏览器都能渲染,完全不需要标志。
可以不受限制地商用吗?基本上可以——它采用 MIT 加 Commons Clause 许可,因此无论是否商用,在自己的项目中都可以免费使用。Commons Clause 只是禁止你把 Canvas UI 本身当作产品转售。
WebGL 和 WebGPU 两种构建有什么区别?WebGL 构建是默认渲染器,直接使用 WebGL2 和 GLSL,除了用于 3D 效果的 three 之外没有其他依赖。WebGPU 构建通过一个叫 vgpu 的库用 WGSL 着色器渲染,保持相同的 props 和 API,但需要支持 WebGPU 的浏览器,如 Chrome/Edge 113+、Safari 26+ 或 Firefox 141+。
一共有多少个组件,覆盖哪些类型的效果?共有 35 个组件,分为几大类:流体与运动(Liquid、Ripple、Cloth)、火焰与能量(Blaze、Force Field、Laser)、玻璃与光学(Glass、Frost、Magnify)、复古与故障(VHS、Glitch、Asciify)、粒子与结构(Shatter、Particle Reveal),此外还有可渲染任意 GLB/glTF 模型、SVG 或图像的 3D 物体效果。
我的 AI 编码助手能帮我安装这些组件吗?可以——组件注册表支持 MCP,Claude Code、Cursor、VS Code、Codex 和 OpenCode 等助手只需一句话就能浏览并安装组件,例如“从 Canvas UI 添加 Liquid 组件”。
3D 物体效果也需要那个特殊的 Chrome 标志吗?不需要——Shatter、Particle Object、Glass Object 等 3D 效果组件在所有浏览器中都能工作,无需任何标志;而 HTML 上屏组件则不同,它们需要 Chrome 的 canvas-draw-element 标志,否则回退到 GPU 覆盖层。
What are similar projects?rare-ui, cult-ui, blobatar, shaders, arc-library, magicui, ui, threeui
Creator
DavidHDev
Size
16.7 MB
Stars
5K
Updated
CommitOct 03
Age
3mo
Commits · 90 Days