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

children
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.
onSelect
function
Callback fired when any menu item is selected (clicked on).

Subcomponents

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

Default Items

Excalidraw provides pre-built menu items accessible via MainMenu.DefaultItems:
MainMenu.DefaultItems.LoadScene
component
Opens a file picker to load a scene from a .excalidraw file.
MainMenu.DefaultItems.SaveToActiveFile
component
Saves the current scene to the active file (requires File System Access API).
MainMenu.DefaultItems.Export
component
Opens the export dialog to save as PNG, SVG, or JSON.
MainMenu.DefaultItems.SaveAsImage
component
Quickly export the canvas as an image.
MainMenu.DefaultItems.Help
component
Opens the help dialog showing keyboard shortcuts.
MainMenu.DefaultItems.ClearCanvas
component
Clears all elements from the canvas.
MainMenu.DefaultItems.ToggleTheme
component
Toggles between light and dark themes.
MainMenu.DefaultItems.ChangeCanvasBackground
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

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

Subcomponents

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

children
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

onSelect
function
required
Callback when button is clicked.
children
React.ReactNode
required
Button content (text, icons, etc.).
type
'button' | 'submit' | 'reset'
default:"button"
HTML button type.
selected
boolean
Whether button is in active/selected state.
className
string
Additional CSS class name for styling.
...rest
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

isCollaborating
boolean
required
Whether collaboration mode is active.
onSelect
function
required
Callback when the button is clicked.
editorInterface
EditorInterface
Editor interface details for responsive behavior.
...rest
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

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

Subcomponents

Stats.StatsRow

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

Stats.StatsRows

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

Example

DefaultSidebar

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

Props

children
React.ReactNode
Custom sidebar tabs to add to the default sidebar.
docked
boolean
Whether the sidebar is docked.
onDock
function | false
Callback when sidebar dock state changes. Pass false to disable docking.
className
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

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

Example

TTDDialog

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

Props

onTextSubmit
function
required
Callback when text is submitted for diagram generation.
renderWelcomeScreen
function
Render custom welcome screen content.
renderWarning
function
Render custom warning message.
persistenceAdapter
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

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

Example

TTDStreamFetch

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

Parameters

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

Example

DiagramToCodePlugin

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

Props

generate
function
required
Function to generate code from the diagram.

Example

CommandPalette

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

Props

customCommandPaletteItems
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