Skip to main content

Excalidraw Component

The Excalidraw component is the main React component that renders the complete Excalidraw editor. It provides a fully-featured, customizable whiteboard experience that can be embedded in any React application.

Basic Usage

Props

Core Props

function
Callback fired when elements, appState, or files change.
object | function
Initial scene data to load. Can be an object or a function that returns initial data (sync or async).
function
Callback to receive the Excalidraw API instance for imperative actions.

Appearance Props

'light' | 'dark'
Sets the editor theme. When not provided, users can toggle between themes.
boolean
default:"false"
When true, renders the editor in view-only mode with no editing capabilities.
boolean
default:"false"
When true, hides the UI chrome for a distraction-free experience.
boolean
default:"false"
When true, shows a grid on the canvas.
string
Name of the document/scene, used as the default filename when exporting.

Behavior Props

boolean
default:"false"
When true, automatically focuses the canvas on mount.
boolean
default:"true"
When true, detects scrolling outside the canvas to prevent accidental scrolls.
boolean
default:"false"
When true, keyboard shortcuts work globally instead of only when canvas is focused.
boolean
Controls whether to render scrollbars on the canvas.

Collaboration Props

boolean
default:"false"
Indicates whether the editor is in collaboration mode.
function
Callback fired when the user’s pointer position changes, useful for real-time collaboration.

Event Callbacks

function
Called on every state increment (ephemeral or durable).
function
Called when paste is triggered. Return true to prevent default paste behavior.
function
Called when elements are duplicated. Return modified elements or void.
function
Called on pointer down events.
function
Called on pointer up events.
function
Called when the canvas scroll position or zoom changes.
function
Called when following a collaborator.

Library & File Management

function
Called when the library items change.
function
Custom function to generate IDs for uploaded files.
string
URL to return to after opening the public library.
Called when a link is clicked.
Generate a custom link for selected element(s).

Embedding

boolean | string[] | RegExp | RegExp[] | function
Controls which URLs can be embedded. Can be a boolean, array of allowed domains, regex pattern(s), or validation function.
function
Custom renderer for embeddable elements.

Custom UI Rendering

function
Render custom UI in the top-left corner.
function
Render custom UI in the top-right corner.
function
Render custom statistics panel content.

UI Configuration

object
Configure which UI elements are displayed and their behavior.

Advanced Props

string
default:"en"
Language code for internationalization. Supported languages include en, es, fr, de, pt, ru, zh, ja, and more.
boolean
default:"true"
When false, disables AI features like text-to-diagram.
boolean
When true, shows deprecated font options.
React.ReactNode
Custom components to render inside Excalidraw, such as MainMenu, WelcomeScreen, Footer, or Sidebar.

Excalidraw API

The imperative API is provided via the excalidrawAPI prop callback:

API Methods

  • updateScene(sceneData) - Update elements and app state
  • resetScene(opts) - Clear the canvas and reset state
  • getSceneElements() - Get current non-deleted elements
  • getSceneElementsIncludingDeleted() - Get all elements
  • getAppState() - Get current app state
  • getFiles() - Get binary files
  • refresh() - Force re-render
  • setToast(message) - Show toast notification
  • setActiveTool(tool) - Change active tool
  • setCursor(cursor) - Set custom cursor
  • resetCursor() - Reset to default cursor
  • toggleSidebar(name) - Toggle sidebar visibility
  • scrollToContent(elements, opts) - Scroll to view specific elements
  • addFiles(files) - Add binary files
  • updateLibrary(libraryItems) - Update library items

API Event Listeners

  • onChange(callback) - Listen to changes (elements, appState, files)
  • onIncrement(callback) - Listen to state increments
  • onPointerDown(callback) - Listen to pointer down events
  • onPointerUp(callback) - Listen to pointer up events
  • onScrollChange(callback) - Listen to scroll/zoom changes
  • onUserFollow(callback) - Listen to user follow events

Complete Example

See Also