TheDocumentation 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.
BaseBoxShapeUtil class extends ShapeUtil to provide common functionality for rectangular shapes that have w (width) and h (height) properties.
Overview
Many shapes in tldraw are fundamentally rectangular: images, videos, frames, and geometric shapes with text.BaseBoxShapeUtil provides default implementations for geometry, resizing, and interpolation that work for these box-based shapes.
Type signature
A shape type that has
w and h properties:Provided implementations
getGeometry()
Returns a filled rectangle geometry based on the shape’s width and height.GeoShapeUtil overrides it to provide different geometries based on the geo type (ellipse, triangle, etc.).
onResize()
Handles shape resizing using the standard box resize behavior.resizeBox helper which:
- Updates width and height based on the resize scale
- Maintains aspect ratio if locked
- Handles negative scales (flipping)
- Updates position based on the resize handle
getHandleSnapGeometry()
Provides snap points at the corners and center of the shape.getInterpolatedProps()
Interpolates width and height for smooth animations.Example: Custom box shape
When to use BaseBoxShapeUtil
UseBaseBoxShapeUtil when:
- Your shape is fundamentally rectangular
- You want standard box resize behavior
- Your shape has
wandhproperties - You want default snap points at corners and center
ShapeUtil directly when:
- Your shape isn’t rectangular (like arrows or freehand)
- You need custom resize behavior
- Your shape uses different dimension properties
Built-in shapes using BaseBoxShapeUtil
GeoShapeUtil- Geometric shapes (rectangle, ellipse, triangle, etc.)ImageShapeUtil- Image shapesVideoShapeUtil- Video shapesFrameShapeUtil- Frame containers