createShapeId

See source code

Creates a new shape ID.

function createShapeId(id?: string): TLShapeId;

Example

// Create a shape with auto-generated ID
const shapeId = createShapeId(); // "shape:abc123"

// Create a shape with custom ID
const customShapeId = createShapeId("my-rectangle"); // "shape:my-rectangle"

// Use in shape creation
const newShape: TLGeoShape = {
  id: createShapeId(),
  type: "geo",
  x: 100,
  y: 200,
  // ... other properties
};

Parameters

NameDescription

id

string;

Optional custom ID suffix. If not provided, a unique ID will be generated

Returns

A new shape ID with the "shape:" prefix

Prev
createPresenceStateDerivation
Next
createShapePropsMigrationIds