Skip to main content

initialData

{ elements?: ExcalidrawElement[], appState?: AppState }

This helps to load Excalidraw with initialData. It must be an object or a promise which resolves to an object containing the below optional fields.

NameTypeDescription
elementsExcalidrawElement[]The elements with which Excalidraw should be mounted.
appStateAppStateThe AppState with which Excalidraw should be mounted.
scrollToContentbooleanThis attribute indicates whether to scroll to the nearest element to center once Excalidraw is mounted. By default, it will not scroll the nearest element to the center. Make sure you pass initialData.appState.scrollX and initialData.appState.scrollY when scrollToContent is false so that scroll positions are retained
libraryItemsLibraryItems | Promise<LibraryItems>This library items with which Excalidraw should be mounted.
filesBinaryFilesThe files added to the scene.

You might want to use this when you want to load excalidraw with some initial elements and app state.

Live Editor
Result
Loading...