Skip to main content

UI Components API

Excalidraw provides a set of composable UI components that can be used to customize the editor interface. These components can be passed as children to the main Excalidraw component.

Import

The MainMenu component provides a customizable dropdown menu accessed via a hamburger icon.

Props

React.ReactNode
required
Menu items and components to display in the dropdown. Can include MainMenu.Item, MainMenu.ItemLink, MainMenu.DefaultItems.*, MainMenu.Separator, MainMenu.Group, and MainMenu.Sub.
function
Callback fired when any menu item is selected (clicked on).

Subcomponents

A clickable menu item that triggers an action.
function
required
Callback when item is clicked.
JSX.Element
Icon to display before the label.
string
Keyboard shortcut to display (e.g., “⌘K”, “Ctrl+S”).
React.ReactNode
required
Label content for the menu item.
A menu item that opens a link in a new tab.
string
required
URL to open when clicked.
JSX.Element
Icon to display before the label.
string
Keyboard shortcut to display.
React.ReactNode
required
Label content for the menu item.
A fully custom menu item with complete control over rendering.
React.ReactNode
required
Custom content to render.
A visual separator between menu items.
No props. Groups related menu items together.
React.ReactNode
required
Menu items to group together.
Creates a submenu.
string
required
Label for the submenu trigger.
JSX.Element
Icon to display before the label.
React.ReactNode
required
Menu items to display in the submenu.
Custom trigger component to open the menu (overrides default hamburger icon).
React.ReactNode
required
Custom trigger element.

Default Items

Excalidraw provides pre-built menu items accessible via MainMenu.DefaultItems:
component
Opens a file picker to load a scene from a .excalidraw file.
component
Saves the current scene to the active file (requires File System Access API).
component
Opens the export dialog to save as PNG, SVG, or JSON.
component
Quickly export the canvas as an image.
component
Opens the help dialog showing keyboard shortcuts.
component
Clears all elements from the canvas.
component
Toggles between light and dark themes.
component
Opens a color picker to change the canvas background.

Example

The Sidebar component provides a customizable sidebar that can be docked or floating.

Props

string
required
Unique name for the sidebar. Used to identify and control the sidebar state.
React.ReactNode
required
Sidebar content including Sidebar.Header, Sidebar.Tabs, Sidebar.Tab, etc.
function
Called on sidebar open/close or tab change.
Parameters:
  • state - Current open sidebar state, or null if closed
function
Supply alongside docked prop to make the sidebar user-dockable.
boolean
Controls whether the sidebar is docked. Must be used with onDock to enable user docking.
string
Additional CSS class name for styling.

Subcomponents

Header component for the sidebar with title and optional dock/close buttons.
React.ReactNode
required
Header content (typically a title).
Button to open/close the sidebar.
string
required
Name of the sidebar to trigger (must match the Sidebar’s name prop).
string
Optional tab name to open when triggering the sidebar.
JSX.Element
Icon to display in the trigger button.
string
Tooltip text for the trigger button.
string
Additional CSS class name.
function
Callback when the trigger is clicked.
React.CSSProperties
Inline styles for the trigger button.
Container for sidebar tabs.
React.ReactNode
required
Sidebar.Tab components.
Individual tab content.
string
required
Unique identifier for the tab.
React.ReactNode
required
Tab content.
Container for tab trigger buttons.
React.ReactNode
required
Sidebar.TabTrigger components.
Button to switch between tabs.
string
required
Tab identifier to activate.
React.ReactNode
required
Tab trigger label.

Example

The Footer component renders the bottom toolbar with zoom controls and undo/redo buttons. It’s exported for use when building custom layouts, but is typically rendered automatically by Excalidraw.
The Footer component is usually rendered automatically. You only need to import it if you’re building a completely custom layout.

WelcomeScreen

The WelcomeScreen component displays a welcome message when the canvas is empty.

Props

React.ReactNode
Custom welcome screen content. If not provided, renders default hints and center content.

Subcomponents

WelcomeScreen.Center

Central welcome message area.
Sub-subcomponents:
  • WelcomeScreen.Center.Logo - Excalidraw logo
  • WelcomeScreen.Center.Heading - Custom heading text
  • WelcomeScreen.Center.Menu - Container for menu items
  • WelcomeScreen.Center.MenuItemLoadScene - Load scene button
  • WelcomeScreen.Center.MenuItemHelp - Help button
  • WelcomeScreen.Center.MenuItemLiveCollaborationTrigger - Collaboration button

WelcomeScreen.Hints

UI hints around the editor.
Available hints:
  • WelcomeScreen.Hints.MenuHint - Points to main menu
  • WelcomeScreen.Hints.ToolbarHint - Points to toolbar
  • WelcomeScreen.Hints.HelpHint - Points to help button

Example

Button

A generic button component that follows Excalidraw’s design system.

Props

function
required
Callback when button is clicked.
React.ReactNode
required
Button content (text, icons, etc.).
'button' | 'submit' | 'reset'
default:"button"
HTML button type.
boolean
Whether button is in active/selected state.
string
Additional CSS class name for styling.
ButtonHTMLAttributes
All standard HTML button attributes are supported (disabled, style, aria-*, etc.).

Example

LiveCollaborationTrigger

A button component for triggering live collaboration mode, displaying the share icon and active collaborator count.

Props

boolean
required
Whether collaboration mode is active.
function
required
Callback when the button is clicked.
EditorInterface
Editor interface details for responsive behavior.
ButtonHTMLAttributes
All standard HTML button attributes are supported.

Example

Complete Example

Here’s a comprehensive example using multiple UI components together:

Styling

All UI components can be styled using CSS classes:

Stats

The Stats component displays canvas statistics and element properties in a floating panel. It provides detailed information about selected elements and the overall scene.

Props

AppClassProperties
required
The Excalidraw app instance.
function
required
Callback when the stats panel is closed.
function
Render custom statistics in the panel.

Subcomponents

Stats.StatsRow

Renders a row in the stats panel.
number
default:"1"
Number of columns in the row grid.
boolean
Whether this row is a heading.

Stats.StatsRows

Container for multiple stat rows with optional ordering.
number
Display order of this stats group.

Example

DefaultSidebar

The DefaultSidebar component provides the default sidebar with library and search functionality.

Props

React.ReactNode
Custom sidebar tabs to add to the default sidebar.
boolean
Whether the sidebar is docked.
function | false
Callback when sidebar dock state changes. Pass false to disable docking.
string
Additional CSS class name.

Subcomponents

DefaultSidebar.Trigger

Trigger button for the default sidebar.

DefaultSidebar.TabTriggers

Container for adding custom tab triggers to the default sidebar.

Example

Ellipsify

A utility component that adds text ellipsis overflow handling.

Props

React.ReactNode
required
Content to ellipsify.
React.HTMLAttributes<HTMLSpanElement>
All standard HTML span attributes are supported.

Example

TTDDialog

Text-to-Diagram dialog component for AI-powered diagram generation.

Props

function
required
Callback when text is submitted for diagram generation.
function
Render custom welcome screen content.
function
Render custom warning message.
TTDPersistenceAdapter
required
Adapter for persisting chat history.

Subcomponents

TTDDialog.WelcomeMessage

Default welcome message component.

Example

TTDDialogTrigger

Trigger button to open the Text-to-Diagram dialog.

Props

React.ReactNode
Custom button label. Defaults to “Text to Diagram”.
JSX.Element
Custom icon for the trigger button.

Example

TTDStreamFetch

Utility function for streaming text-to-diagram API responses.

Parameters

string
required
API endpoint URL for streaming.
readonly LLMMessage[]
required
Array of messages to send to the LLM.
function
Callback for each chunk of streamed text.
boolean
default:"true"
Whether to extract rate limit headers from the response.
AbortSignal
AbortSignal for cancelling the request.
function
Callback when the stream is created.

Example

DiagramToCodePlugin

Plugin component for adding diagram-to-code conversion functionality.

Props

function
required
Function to generate code from the diagram.

Example

CommandPalette

Command palette component for quick access to editor actions via keyboard shortcuts.

Props

CommandPaletteItem[]
Custom commands to add to the palette.

Default Items

The CommandPalette.defaultItems export provides access to pre-built command items:

Example

The command palette opens with Cmd/Ctrl + Shift + P or Cmd/Ctrl + /.

Hooks

useEditorInterface

Hook to access the editor’s interface information including form factor and sidebar visibility.
Example:

useStylesPanelMode

Hook to get the current styles panel mode derived from the editor interface.
Example:

See Also