Canvas UI
An open source component library of creative html-in-canvas and WebGL effects for React, Solid, Preact, Vue, Svelte, and vanilla JS to animate live web content.
Canvas UI is an open source component library that provides a collection of high-performance, creative effects for modern web development. Created by David Haz, it utilizes the experimental html-in-canvas API to render live HTML content inside a canvas element, enabling complex WebGL effects to be applied directly over functional, interactive DOM elements. This approach eliminates the need for workarounds like iframes or static image snapshots.
The library is intentionally framework-agnostic, providing native support for React, Solid, Preact, Vue, Svelte, and vanilla TypeScript. Each component is designed to be self-contained and easily integrated into existing projects. The project follows the shadcn registry pattern, which means users can use a command-line interface to pull the component source code directly into their own codebase. This ensures complete ownership of the implementation, allowing developers to tune parameters, restyle components, or refactor the code to meet specific project requirements without being locked into a proprietary package or dealing with versioning constraints.
Some of the key features are:
- Framework Agnostic: Every component ships with support for React, Solid, Preact, Vue, Svelte, and vanilla TypeScript using a unified engine.
- Live HTML Integration: Uses the html-in-canvas API to manipulate DOM content directly, ensuring interactivity is maintained while visual effects are applied.
- Shader-Based Performance: Effects are rendered on the GPU via WebGL, ensuring minimal impact on the main thread and smooth performance.
- shadcn Registry Integration: Components are installed as source code, giving developers full control and auditability of the implementation.
- Graceful Degradation: Components detect feature support at runtime, ensuring that if the experimental API is not available, the page remains functional with pure HTML or simplified WebGL effects.
- AI-Ready: The registry is compatible with the shadcn MCP server, allowing AI coding assistants to browse, preview, and install components via natural language prompts.
Operationally, Canvas UI components are installed via a CLI command. Once integrated into a project, they function as wrapper elements. Developers pass their standard HTML interface as children to these components. The effect then automatically hooks into the component lifecycle—initializing when mounted, pausing when off-screen, and cleaning up on unmount—to optimize GPU usage and respect user reduced-motion preferences.
Some common use cases include:
- Hero Sections: Creating high-impact, interactive hero sections with particle reveals, liquid simulations, or fire effects that draw user attention.
- Creative Portfolio Enhancements: Applying artistic filters like ASCII conversion, vintage VHS effects, or glass refraction to static UI elements.
- Micro-Interactions: Adding subtle, performant feedback to UI components, such as ripples, magnification, or hover-triggered shattering effects.
- Immersive Narrative Pages: Using scroll-triggered effects like bending or particle transitions to create engaging, non-linear reading experiences.