Skip to main content
This guide will help you integrate Excalidraw into your application and start drawing in just 5 minutes.

Basic Setup

1

Install Excalidraw

2

Create your first canvas

Create a simple drawing canvas with minimal configuration:
App.tsx
That’s it! You now have a fully functional drawing canvas with all of Excalidraw’s features.

Working with the Canvas

Getting the API Reference

Access the Excalidraw API to programmatically control the canvas:
The API instance is passed to the excalidrawAPI callback when the component mounts. Store it in state or a ref to use it throughout your component.

Listening to Changes

Track when users modify the canvas using the onChange callback:
The onChange callback fires frequently during drawing operations. Consider debouncing or throttling if you’re performing expensive operations like saving to a database.

Loading Initial Data

Loading a Scene

Load predefined elements when the canvas initializes:

Loading with Images

Load a scene that includes images:

Updating the Scene Programmatically

Adding New Elements

Add elements to the canvas using the API:

Changing Background Color

Update the canvas background color:

View Modes

Excalidraw supports different view modes for various use cases:
Enables read-only mode. Users can view and pan/zoom the canvas but cannot edit elements.
Hides the UI and shows only the canvas for distraction-free viewing or presenting.
Displays a grid overlay on the canvas to help with alignment.

Theme Support

Switch between light and dark themes:
If you don’t set a theme prop, Excalidraw will show a theme toggle button in the UI. Setting the theme prop hides the toggle button and locks the theme to your specified value.

Exporting Drawings

Export to PNG

Export the current canvas as a PNG image:

Export to SVG

Export as a scalable SVG image:

Export to Clipboard

Copy the drawing to the clipboard:

Customizing the UI

Hiding UI Elements

Control which UI elements are visible:

Custom UI Components

Add custom UI elements using the children prop:

Complete Example

Here’s a complete example combining all the concepts:

What’s Next?

API Reference

Explore all available props and configuration options

Event Handling

Learn about all event callbacks and their use cases

Custom UI

Build custom UI components and integrate them with Excalidraw

Collaboration

Add real-time collaboration to your canvas
Need Help? Check out our examples for more real-world use cases, or join our Discord community to ask questions.