TLBaseAsset

See source code
Table of contents

Extends BaseRecord<'asset', TLAssetId>.

Base interface for all asset records in tldraw. Assets represent external resources like images, videos, or bookmarks that shapes can reference. This interface extends the base record system with asset-specific typing.

interface TLBaseAsset<Type extends string, Props>
  extends BaseRecord<'asset', TLAssetId> {}

Example

// Define a custom asset type
interface MyCustomAsset
  extends TLBaseAsset<'custom', { url: string; title: string }> {}

const customAsset: MyCustomAsset = {
  id: 'asset:custom123',
  typeName: 'asset',
  type: 'custom',
  props: {
    url: 'https://example.com',
    title: 'My Custom Asset',
  },
  meta: {},
}

Parameters

NameDescription

Type

The specific asset type identifier (e.g., 'image', 'video', 'bookmark')

Props

The properties object specific to this asset type


Properties

id

readonly
readonly id: Id

meta

User-defined metadata that can be attached to this asset

meta: JsonObject

props

Type-specific properties for this asset

props: Props

type

The specific type of this asset (e.g., 'image', 'video', 'bookmark')

type: Type

typeName

readonly
readonly typeName: TypeName

Prev
TLAssetStore
Next
TLBaseBinding