Options

The tldraw editor accepts two kinds of configuration: editor options for core behavior (timing, limits, performance) and component props for features like persistence and custom shapes. Editor options are immutable after initialization; component props configure how the editor sets up.

Editor options

The options prop accepts a Partial<TldrawOptions> object that configures core editor behavior: limits like maximum pages and shapes, timing for interactions and animations, sizing for handles and hit testing, and feature toggles.

Options are set once when the editor initializes and cannot change afterward. Pass a partial options object to override specific values; everything else uses sensible defaults.

import { Tldraw, TldrawOptions } from 'tldraw'

const options: Partial<TldrawOptions> = {
	maxPages: 3,
	maxShapesPerPage: 1000,
}

function App() {
	return <Tldraw options={options} />
}

The TldrawOptions type defines all available options. Since you typically only need to customize a few values, pass Partial<TldrawOptions> to override specific options while accepting defaults for the rest.

Reading options at runtime

After the editor initializes, access options through editor.options:

const maxPages = editor.options.maxPages
const animationDuration = editor.options.animationMediumMs

The options object is readonly. Attempting to modify it has no effect and TypeScript will flag the error.

Editor option categories

Limits

Control maximum quantities to prevent performance issues or enforce business rules:

OptionDefaultDescription
maxShapesPerPage4000Maximum shapes allowed on one page
maxPages40Maximum pages in a document
maxFilesAtOnce100Maximum files to handle in one drop

Setting maxPages to 1 effectively disables multi-page functionality and removes the page menu from the UI.

Interaction timing

Configure how the editor interprets user input timing:

OptionDefaultDescription
doubleClickDurationMs450Maximum interval for double-click detection
multiClickDurationMs200Maximum interval for triple/quadruple click
longPressDurationMs500Duration to trigger long press
animationMediumMs320Duration for camera animations (zoom, pan to fit)

Drag detection

Control when pointer movement becomes a drag operation:

OptionDefaultDescription
dragDistanceSquared16Distance² threshold for mouse drag (4px)
coarseDragDistanceSquared36Distance² threshold for touch drag (6px)
uiDragDistanceSquared16Distance² for UI element drag (4px)
uiCoarseDragDistanceSquared625Distance² for touch UI drag (25px)

Values are squared to avoid computing square roots during hit testing. The larger touch thresholds prevent accidental drags on mobile devices.

Handle and hit testing

Configure selection handles and click target areas:

OptionDefaultDescription
handleRadius12Radius of selection handles
coarseHandleRadius20Handle radius for touch input
coarsePointerWidth12Expanded pointer size for touch
hitTestMargin8Additional margin around shapes for hit tests

Edge scrolling

Configure auto-scroll behavior when dragging near viewport edges:

OptionDefaultDescription
edgeScrollDelay200Milliseconds before scroll starts
edgeScrollEaseDuration200Milliseconds to accelerate to full speed
edgeScrollSpeed25Base scroll speed in pixels per tick
edgeScrollDistance8Width of the edge scroll trigger zone

See Edge scrolling for details on how these options affect behavior.

Camera

Control camera movement and viewport behavior:

OptionDefaultDescription
cameraSlideFriction0.09Friction applied to camera momentum
cameraMovingTimeoutMs64Time before camera is considered stopped
followChaseViewportSnap2Snap threshold when following collaborators
spacebarPanningtrueEnable spacebar to activate pan mode
zoomToFitPadding128Padding around content when zooming to fit bounds

Snapping

OptionDefaultDescription
snapThreshold8Distance in pixels at which snapping engages

Collaboration

Configure timing for collaborator presence:

OptionDefaultDescription
collaboratorInactiveTimeoutMs60000Time before collaborator marked inactive
collaboratorIdleTimeoutMs3000Time before collaborator marked idle
collaboratorCheckIntervalMs1200Interval for checking collaborator status

Export

Configure image and SVG export behavior:

OptionDefaultDescription
defaultSvgPadding32Padding around exported SVG content
maxExportDelayMs5000Maximum wait time for export completion
flattenImageBoundsExpand64Expansion when flattening images
flattenImageBoundsPadding16Padding when flattening images
exportProviderFragmentReact provider wrapping exported content

The exportProvider option wraps exported content in a React component. Use this when your custom shapes depend on context providers that must be present during rendering:

const options: Partial<TldrawOptions> = {
	exportProvider: ({ children }) => <ThemeProvider theme={myTheme}>{children}</ThemeProvider>,
}

Grid

Configure the alignment grid:

gridSteps: [
	{ min: -1, mid: 0.15, step: 64 },
	{ min: 0.05, mid: 0.375, step: 16 },
	{ min: 0.15, mid: 1, step: 4 },
	{ min: 0.7, mid: 2.5, step: 1 },
]

Each entry defines a grid step size based on zoom level. The min and mid values define the zoom range where the step applies. At lower zoom levels, larger grid steps are used; at higher zoom levels, finer grid steps appear.

Performance

Options that affect rendering performance:

OptionDefaultDescription
debouncedZoomtrueUse cached zoom while camera is moving
debouncedZoomThreshold500Shape count threshold for debounced zoom
maxFontsToLoadBeforeRenderInfinityFonts to load before showing canvas
textShadowLod0.35Zoom threshold for text shadow rendering

When debouncedZoom is enabled and the page has more shapes than debouncedZoomThreshold, the editor returns a cached zoom level during camera movement. This reduces re-renders of complex documents.

UI and features

OptionDefaultDescription
createTextOnCanvasDoubleClicktrueCreate text shape on empty canvas double-click
enableToolbarKeyboardShortcutstrueEnable number keys (1-9) for toolbar items
actionShortcutsLocation'swap'Where to show keyboard shortcuts in menus
tooltipDelayMs700Delay before showing tooltips
laserDelayMs1200Duration laser pointer remains visible
brandingundefinedApp name for accessibility labels
nonceundefinedCSP nonce for inline styles

The actionShortcutsLocation option controls where keyboard shortcuts appear:

  • 'menu' - Show shortcuts in menu items only
  • 'toolbar' - Show shortcuts in toolbar tooltips only
  • 'swap' - Show in menus when toolbar is collapsed, toolbar when expanded

Asset handling

OptionDefaultDescription
temporaryAssetPreviewLifetimeMs180000How long temporary asset previews persist (3 min)
adjacentShapeMargin10Margin between auto-positioned shapes

Default values

The defaultTldrawOptions export provides all default values:

import { defaultTldrawOptions } from 'tldraw'

console.log(defaultTldrawOptions.maxPages) // 40

Use this to check defaults or spread into your own options:

const options: Partial<TldrawOptions> = {
	...defaultTldrawOptions,
	maxPages: 10,
}

Tldraw component props

The <Tldraw> component accepts additional props beyond those available on <TldrawEditor>. These props configure the UI layer, external content handling, and other features that the full SDK provides.

UI configuration

PropTypeDescription
hideUibooleanHide all UI elements, showing only the canvas
forceMobilebooleanForce mobile breakpoints regardless of screen size
overridesTLUiOverridesOverride actions, tools, and translations
onUiEventTLUiEventHandlerCallback for UI interaction events
componentsTLComponentsOverride or disable UI and canvas components
assetUrlsTLUiAssetUrlOverridesCustom URLs for fonts, icons, and other UI assets

The hideUi prop is useful when building custom interfaces around the canvas:

function CustomEditor() {
	return (
		<Tldraw hideUi>
			<MyCustomToolbar />
		</Tldraw>
	)
}

External content handling

These props control how the editor handles dropped or pasted files:

PropDefaultDescription
maxImageDimension5000Maximum width/height for images (larger images resized)
maxAssetSize10485760Maximum file size in bytes (10 MB)
acceptedImageMimeTypesDEFAULT_SUPPORTED_IMAGE_TYPESAllowed image MIME types
acceptedVideoMimeTypesDEFAULT_SUPPORT_VIDEO_TYPESAllowed video MIME types
function App() {
	return (
		<Tldraw
			maxImageDimension={2000}
			maxAssetSize={5 * 1024 * 1024} // 5 MB
			acceptedImageMimeTypes={['image/png', 'image/jpeg']}
		/>
	)
}

Embeds

The embeds prop customizes which embed types the editor recognizes:

import { Tldraw, TLEmbedDefinition } from 'tldraw'

const customEmbeds: TLEmbedDefinition[] = [
	{
		type: 'custom-video',
		title: 'Custom Video',
		hostnames: ['videos.example.com'],
		width: 560,
		height: 315,
		doesResize: true,
		toEmbedUrl: (url) => url.replace('/watch/', '/embed/'),
		fromEmbedUrl: (url) => url.replace('/embed/', '/watch/'),
	},
]

function App() {
	return <Tldraw embeds={customEmbeds} />
}

Editor setup

These props configure how the editor initializes:

PropTypeDescription
autoFocusbooleanAutomatically focus the editor on mount
initialStatestringInitial tool state (defaults to 'select')
shapeUtilsTLShapeUtilConstructor[]Custom shape utilities
bindingUtilsTLBindingUtilConstructor[]Custom binding utilities
toolsTLStateNodeConstructor[]Custom tools
onMountTLOnMountHandlerCallback when editor mounts
cameraOptionsPartial<TLCameraOptions>Camera constraints and behavior
textOptionsTLTextOptionsRich text editor configuration
deepLinkstrue | TLDeepLinkOptionsSync camera state with URL
getShapeVisibility(shape, editor) => 'visible' | 'hidden' | 'inherit'Conditionally hide shapes
userTLUserCurrent user information
inferDarkModebooleanInfer dark mode from OS preference
licenseKeystringLicense key to remove watermark

The getShapeVisibility callback lets you conditionally hide shapes based on their properties:

<Tldraw
	getShapeVisibility={(shape, editor) => {
		// Hide shapes marked as hidden in meta
		if (shape.meta.hidden) return 'hidden'
		// Force-show shapes regardless of parent visibility
		if (shape.meta.alwaysVisible) return 'visible'
		// Default: visible unless parent is hidden
		return 'inherit'
	}}
/>

Store configuration

When not providing your own store, these props configure automatic store creation:

PropTypeDescription
persistenceKeystringKey for IndexedDB persistence (enables local storage)
sessionIdstringSession identifier for persistence
snapshotTLEditorSnapshotInitial document state
migrationsMigrationSequence[]Additional migrations for custom schemas
function App() {
	return <Tldraw persistenceKey="my-document" snapshot={savedSnapshot} />
}

Alternatively, provide your own store with the store prop for full control over data management.

Examples

  • Editor options - Override default options like max pages and animation speed.
  • Disable pages - Set maxPages to 1 to create a single-page editor.
Prev
Note shape
Next
Pages