Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tsdraw.com/llms.txt

Use this file to discover all available pages before exploring further.

TsdrawProps

All props are optional.
PropTypeDefaultDescription
widthnumber | stringCanvas width
heightnumber | stringCanvas height
classNamestringCSS class for the root element
styleCSSPropertiesInline styles for the root element
theme'light' | 'dark' | 'system''system'Color theme
persistenceKeystringIndexedDB storage key; enables persistence and cross-tab sync
customToolsTsdrawCustomTool[][]Additional tools to register
initialToolIdToolIdTool that’s active on mount
uiOptionsTsdrawUiOptionsToolbar, style panel, cursors, overlays
onMount(api: TsdrawMountApi) => void | (() => void)Called when the editor is ready; return a cleanup function
cameraOptionsTsdrawCameraOptionsZoom range and camera behavior
touchOptionsTsdrawTouchOptionsTouch gesture toggles
keyboardShortcutsTsdrawKeyboardShortcutOptionsKeyboard shortcut overrides
penOptionsTsdrawPenOptionsPressure sensitivity settings
backgroundTsdrawBackgroundOptions{ type: 'blank' }Canvas background pattern
readOnlybooleanfalseDisable drawing and erasing
autoFocusbooleanTake focus on mount
snapshotTsdrawEditorSnapshotInitial editor state
onChange(snapshot: TsdrawDocumentSnapshot) => voidDocument change callback
onCameraChange(viewport: Viewport) => voidCamera change callback
onToolChange(toolId: ToolId) => voidTool switch callback

TsdrawUiOptions

PropertyTypeDescription
toolbar.hidebooleanHide the toolbar
toolbar.placementTsdrawUiPlacementToolbar anchor and offset
toolbar.partsToolbarPartItem[][]Toolbar layout (groups of tool IDs and actions)
toolbar.draggablebooleanAllow dragging the toolbar
toolbar.saveDraggedPositionbooleanPersist dragged position in session storage
toolbar.disabledDragPositionsUiAnchor[]Anchors where the toolbar can’t be dropped
stylePanel.hidebooleanHide the style panel
stylePanel.placementTsdrawUiPlacementStyle panel anchor and offset
customElementsTsdrawCustomElement[]Extra UI elements to render on the canvas
cursor.getCursor(ctx: TsdrawCursorContext) => stringCustom cursor logic
overlays.renderToolOverlay(args) => ReactNodeCustom tool overlay rendering

TsdrawCustomTool

PropertyTypeDescription
idToolIdUnique tool identifier
labelstringDisplay name
iconReactNodeToolbar icon
iconSelectedReactNodeIcon when tool is active (optional)
definitionToolDefinitionEngine-level tool definition
stylePanel{ parts?, customParts? }Style panel config for this tool

TsdrawMountApi

Provided to the onMount callback:
PropertyTypeDescription
editorEditorThe core editor instance