TldrawEditorBaseProps

See source code
Table of contents

Base props for the Tldraw and TldrawEditor components.

interface TldrawEditorBaseProps {}

Properties

assetUrls

optional

The URLs for the fonts to use in the editor.

assetUrls?: {
  fonts?: {
    [key: string]: string | undefined;
  };
};

assetUtils

optional

An array of asset utils to use in the editor.

assetUtils?: readonly TLAnyAssetUtilConstructor[];

autoFocus

optional

Whether to automatically focus the editor when it mounts.

autoFocus?: boolean;

bindingUtils

optional

An array of binding utils to use in the editor.

bindingUtils?: readonly TLAnyBindingUtilConstructor[];

cameraOptions

optional

Deprecated: Use options.cameraOptions instead. This will be removed in a future release.

Camera options for the editor.

cameraOptions?: Partial<TLCameraOptions>;

children

optional

The component's children.

children?: ReactNode;

className

optional

A classname to pass to the editor's container.

className?: string;

colorScheme

optional

The editor's color scheme. Defaults to 'light'.

  • 'light' - Always use light mode. - 'dark' - Always use dark mode. - 'system' - Follow the OS color scheme preference.
colorScheme?: "dark" | "light" | "system";

components

optional

Overrides for the editor's components, such as handles, collaborator cursors, etc.

components?: TLEditorComponents;

optional

Deprecated: Use options.deepLinks instead. This prop will be removed in a future release.

Options for syncing the editor's camera state with the URL.

deepLinks?: TLDeepLinkOptions | true;

initialState

optional

The editor's initial state (usually the id of the first active tool).

initialState?: string;

initialTheme

optional

The id of the initially active theme. Defaults to 'default'.

initialTheme?: TLThemeId;

licenseKey

optional

The license key.

licenseKey?: string;

onMount

optional

Called when the editor has mounted.

onMount?: TLOnMountHandler;

options

optional

Options for the editor.

options?: Partial<TldrawOptions>;

shapeUtils

optional

An array of shape utils to use in the editor.

shapeUtils?: readonly TLAnyShapeUtilConstructor[];

textOptions

optional

Deprecated: Use options.text instead. This prop will be removed in a future release.

Text options for the editor.

textOptions?: TLTextOptions;

themes

optional

Named themes for the editor.

themes?: Partial<TLThemes>;

tools

optional

An array of tools to add to the editor's state chart.

tools?: readonly TLStateNodeConstructor[];

user

optional

The user interacting with the editor.

user?: TLCurrentUser;

Methods

getShapeVisibility

optional

Provides a way to hide shapes.

Hidden shapes will not render in the editor, and they will not be eligible for hit test via Editor.getShapeAtPoint and Editor.getShapesAtPoint. But otherwise they will remain in the store and participate in all other operations.

Example

getShapeVisibility={(shape, editor) => shape.meta.hidden ? 'hidden' : 'inherit'}
  • 'inherit' | undefined - (default) The shape will be visible unless its parent is hidden. - 'hidden' - The shape will be hidden. - 'visible' - The shape will be visible.

Parameters

NameDescription

shape

TLShape;

The shape to check.

editor

Editor;

The editor instance.

Returns

"hidden" | "inherit" | "visible" | null | undefined;

Prev
TLDragShapesOverInfo
Next
TldrawEditorWithoutStoreProps