TLBaseShape
See source codeTable of contents
Extends BaseRecord<'shape', TLShapeId>.
Base interface for all shapes in tldraw.
This interface defines the common properties that all shapes share, regardless of their specific type. Every shape extends this base with additional type-specific properties.
interface TLBaseShape<Type extends string, Props extends object>
extends BaseRecord<'shape', TLShapeId> {}Example
// Define a custom shape type
interface MyCustomShape
extends TLBaseShape<'custom', { size: number; color: string }> {}
// Create a shape instance
const myShape: MyCustomShape = {
id: 'shape:abc123',
typeName: 'shape',
type: 'custom',
x: 100,
y: 200,
rotation: 0,
index: 'a1',
parentId: 'page:main',
isLocked: false,
opacity: 1,
props: {
size: 50,
color: 'blue',
},
meta: {},
}Properties
id
readonly
from BaseRecord
readonly id: Idindex
index: IndexKeyisLocked
isLocked: booleanmeta
meta: JsonObjectopacity
opacity: TLOpacityTypeparentId
parentId: TLParentIdprops
props: Propsrotation
rotation: numbertype
type: TypetypeName
readonly
from BaseRecord
readonly typeName: TypeNamex
x: numbery
y: numberPrev
TLBaseBindingNext
TLBookmarkShapeProps