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 mainExcalidraw component.
Import
MainMenu
TheMainMenu 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
MainMenu.Item
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.
MainMenu.ItemLink
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.
MainMenu.ItemCustom
A fully custom menu item with complete control over rendering.React.ReactNode
required
Custom content to render.
MainMenu.Separator
A visual separator between menu items.MainMenu.Group
Groups related menu items together.React.ReactNode
required
Menu items to group together.
MainMenu.Sub
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.
MainMenu.Trigger
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 viaMainMenu.DefaultItems:
Opens a file picker to load a scene from a .excalidraw file.
Saves the current scene to the active file (requires File System Access API).
Opens the export dialog to save as PNG, SVG, or JSON.
Quickly export the canvas as an image.
Opens the help dialog showing keyboard shortcuts.
Clears all elements from the canvas.
Toggles between light and dark themes.
Opens a color picker to change the canvas background.
Example
Sidebar
TheSidebar 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, ornullif 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
Sidebar.Header
Header component for the sidebar with title and optional dock/close buttons.React.ReactNode
required
Header content (typically a title).
Sidebar.Trigger
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.
Sidebar.Tabs
Container for sidebar tabs.React.ReactNode
required
Sidebar.Tab components.Sidebar.Tab
Individual tab content.string
required
Unique identifier for the tab.
React.ReactNode
required
Tab content.
Sidebar.TabTriggers
Container for tab trigger buttons.React.ReactNode
required
Sidebar.TabTrigger components.Sidebar.TabTrigger
Button to switch between tabs.string
required
Tab identifier to activate.
React.ReactNode
required
Tab trigger label.
Example
Footer
TheFooter 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
TheWelcomeScreen 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.WelcomeScreen.Center.Logo- Excalidraw logoWelcomeScreen.Center.Heading- Custom heading textWelcomeScreen.Center.Menu- Container for menu itemsWelcomeScreen.Center.MenuItemLoadScene- Load scene buttonWelcomeScreen.Center.MenuItemHelp- Help buttonWelcomeScreen.Center.MenuItemLiveCollaborationTrigger- Collaboration button
WelcomeScreen.Hints
UI hints around the editor.WelcomeScreen.Hints.MenuHint- Points to main menuWelcomeScreen.Hints.ToolbarHint- Points to toolbarWelcomeScreen.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
TheStats 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
TheDefaultSidebar 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
TheCommandPalette.defaultItems export provides access to pre-built command items:
Example
Cmd/Ctrl + Shift + P or Cmd/Ctrl + /.
Hooks
useEditorInterface
Hook to access the editor’s interface information including form factor and sidebar visibility.useStylesPanelMode
Hook to get the current styles panel mode derived from the editor interface.See Also
- Excalidraw Component API - Main component API reference
- MainMenu - MainMenu usage guide
- Sidebar - Sidebar usage guide
- WelcomeScreen - WelcomeScreen usage guide
- Customization Guide - Customize component appearance