The tldraw shape system provides a flexible, type-safe architecture for creating custom shapes with full control over geometry, rendering, and interactions. Every shape in tldraw is powered by a ShapeUtil class that defines its behavior.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tldraw/tldraw/llms.txt
Use this file to discover all available pages before exploring further.
Core concepts
The shape system is built on three foundational concepts:Shape data
Type-safe shape records stored in the editor’s reactive store
ShapeUtil classes
Define how shapes behave, render, and respond to interactions
Geometry primitives
Mathematical representations for hit testing and bounds calculation
Shape anatomy
Every shape in tldraw consists of:Shape record
A shape record is stored in the editor’s store and contains:ShapeUtil class
A ShapeUtil defines the shape’s behavior and appearance:Built-in shapes
The@tldraw/tldraw package includes these shape implementations:
Basic shapes
Basic shapes
- Geo - Rectangles, ellipses, triangles, stars, and more geometric primitives
- Text - Auto-sizing or fixed-width text with rich formatting
- Draw - Freehand drawing with pen pressure support
- Line - Straight lines with optional arrowheads
Advanced shapes
Advanced shapes
- Arrow - Smart arrows with binding, labels, and multiple routing types (straight, arc, elbow)
- Note - Sticky notes with auto-growing text
- Highlight - Highlighter pen for annotations
Container shapes
Container shapes
- Frame - Frames for grouping and clipping child shapes
- Group - Logical grouping without visual container
Media shapes
Media shapes
- Image - Raster images with optional cropping
- Video - Embedded video players
- Embed - iFrame embeds for external content
- Bookmark - Link preview cards
Shape lifecycle
Shapes go through a predictable lifecycle:Lifecycle hooks
ShapeUtil provides hooks to intercept shape changes:Shape validation
Shapes define their props schema using validators:- Type safety at runtime
- Automatic validation on create/update
- Style prop persistence across shape creation
Shape migrations
When shape props change between versions, migrations handle data transformation:Migrations run automatically when loading documents created with older versions of your shape.
Registering custom shapes
To use custom shapes, register them with the editor:Next steps
ShapeUtil API
Learn about ShapeUtil methods and lifecycle hooks
Geometry system
Understand how shapes define their geometry
Rendering
Control how shapes appear on the canvas
Interactions
Handle user interactions and events