TLBaseShape

See source code
Table 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
readonly id: Id

index

index: IndexKey

isLocked

isLocked: boolean

meta

meta: JsonObject

opacity

opacity: TLOpacityType

parentId

parentId: TLParentId

props

props: Props

rotation

rotation: number

type

type: Type

typeName

readonly
readonly typeName: TypeName

x

x: number

y

y: number

Prev
TLBaseBinding
Next
TLBookmarkShapeProps