TLDocument

See source code
Table of contents

Extends BaseRecord<'document', RecordId<TLDocument>>.

Document record containing global settings and metadata for a tldraw document. There is exactly one document record per tldraw instance with a fixed ID.

interface TLDocument extends BaseRecord<"document", RecordId<TLDocument>> {}

Example

const document: TLDocument = {
  id: "document:document",
  typeName: "document",
  gridSize: 20, // Grid snap size in pixels
  name: "My Drawing", // Document name
  meta: {
    createdAt: Date.now(),
    author: "user123",
    version: "1.0.0",
  },
};

// Update document settings
editor.updateDocumentSettings({
  name: "Updated Drawing",
  gridSize: 25,
});

Properties

gridSize

Grid snap size in pixels. Used for shape positioning and alignment

gridSize: number;

id

readonly
readonly id: Id;

meta

User-defined metadata for the document

meta: JsonObject;

name

Human-readable name of the document

name: string;

typeName

readonly
readonly typeName: TypeName;

Prev
TLDefaultColorThemeColor
Next
TLDrawShapeProps