tldraw — Infinite Canvas SDK for AI Applications
Open-source infinite canvas library for building whiteboard, diagramming, and design applications. React component with real-time collaboration. Used by AI tools for visual generation. 40,000+ stars.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install abe1c221-d226-4a39-83c8-68ceda7885a0 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
tldraw is an open-source infinite canvas library for building whiteboard, diagramming, and design applications. It provides a React component with drawing tools, shape primitives, text, images, and real-time collaboration out of the box.
tldraw is used by AI tools for visual generation, letting users sketch interfaces or diagrams that AI can interpret and convert to code or structured data. The library has over 40,000 GitHub stars and is used in production by multiple companies.
How it saves time or tokens
Building a canvas editor from scratch requires handling pointer events, coordinate transforms, shape rendering, undo/redo, selection, snapping, and multi-user sync. tldraw provides all of this as a single React component. Drop it into your app and you have a working canvas editor.
For AI applications, tldraw's structured shape data means you can export a user's drawing as JSON and feed it to an LLM for interpretation, reducing the need for expensive vision model calls.
How to use
- Install tldraw:
npm install tldraw
- Add the canvas to your React app:
import { Tldraw } from 'tldraw';
import 'tldraw/tldraw.css';
export default function App() {
return (
<div style={{ width: '100vw', height: '100vh' }}>
<Tldraw />
</div>
);
}
- Customize tools, shapes, and UI using tldraw's extensibility API.
- Export canvas state as JSON for processing by AI models or backend services.
Example
import { Tldraw, useEditor } from 'tldraw';
function ExportButton() {
const editor = useEditor();
const handleExport = () => {
const shapes = editor.getCurrentPageShapes();
console.log(JSON.stringify(shapes, null, 2));
};
return <button onClick={handleExport}>Export Shapes</button>;
}
function App() {
return (
<Tldraw>
<ExportButton />
</Tldraw>
);
}
Related on TokRepo
- AI Tools for Design — AI-powered design and visual generation tools
- AI Tools for Coding — Tools that convert visual designs to code
Common pitfalls
- Not importing the CSS file. tldraw requires
tldraw/tldraw.cssfor proper rendering. Without it, the canvas renders but tools and menus are unstyled. - Treating tldraw as a vector graphics editor. It is a canvas SDK for building custom editors, not a replacement for Figma or Illustrator. Use the extensibility API to build the editor your users need.
- Ignoring performance with large shape counts. Canvases with thousands of shapes may need viewport culling and pagination strategies.
- Failing to review community discussions and changelogs before upgrading. Breaking changes in major versions can disrupt existing workflows. Pin versions in production and test upgrades in staging first.
常见问题
tldraw is used for building whiteboard applications, diagramming tools, visual collaboration platforms, and AI-powered design tools. It provides the canvas rendering, shape management, and interaction handling so you can focus on your application logic.
tldraw exports canvas state as structured JSON. AI applications can read this JSON to interpret user drawings, convert sketches to code, or generate design suggestions. Some AI tools use tldraw as an input canvas where users sketch UI mockups that an LLM converts to working code.
Yes. tldraw includes built-in support for real-time collaboration using WebSocket sync. Multiple users can draw on the same canvas simultaneously with live cursor and selection visibility.
Yes. tldraw has an extensibility API for creating custom shapes, tools, and UI components. You can add domain-specific shapes (like flowchart nodes or UML elements) and custom interaction behaviors while keeping the core canvas functionality.
tldraw uses a dual license. The core library is open-source, but commercial use may require a license depending on your deployment model. Check the tldraw license terms for your specific use case.
引用来源 (3)
- tldraw GitHub— tldraw is an open-source infinite canvas library with 40,000+ GitHub stars
- tldraw Documentation— tldraw documentation and API reference
- React Documentation— React component architecture for canvas applications
来源与感谢
讨论
相关资产
Chart.js — Simple Yet Flexible HTML5 Canvas Charts
Chart.js is the most popular charting library for the web — simple HTML5 canvas charts with 8 built-in chart types, responsive, animated, and mixable. The go-to choice when you need beautiful charts with minimal setup.
Canvas LMS — Open-Source Learning Management System
Modern learning management system used by schools, universities, and corporations worldwide. Provides course creation, assignments, grading, video conferencing integration, and a mobile-friendly interface.
Craft.js — React Framework for Extensible Drag-and-Drop Page Editors
A React framework for building drag-and-drop page editors where every element on the canvas is a real React component, giving developers full control over the editing experience.
Motion Canvas — Create Animated Videos with Code
A TypeScript library and editor for creating publication-quality animated videos programmatically, combining the precision of code with a visual preview workflow.