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
Menu items and components to display in the dropdown. Can include
MainMenu.Item, MainMenu.ItemLink, MainMenu.DefaultItems.*, MainMenu.Separator, MainMenu.Group, and MainMenu.Sub.Callback fired when any menu item is selected (clicked on).
Subcomponents
MainMenu.Item
A clickable menu item that triggers an action.Callback when item is clicked.
Icon to display before the label.
Keyboard shortcut to display (e.g., “⌘K”, “Ctrl+S”).
Label content for the menu item.
MainMenu.ItemLink
A menu item that opens a link in a new tab.URL to open when clicked.
Icon to display before the label.
Keyboard shortcut to display.
Label content for the menu item.
MainMenu.ItemCustom
A fully custom menu item with complete control over rendering.Custom content to render.
MainMenu.Separator
A visual separator between menu items.MainMenu.Group
Groups related menu items together.Menu items to group together.
MainMenu.Sub
Creates a submenu.Label for the submenu trigger.
Icon to display before the label.
Menu items to display in the submenu.
MainMenu.Trigger
Custom trigger component to open the menu (overrides default hamburger icon).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
Unique name for the sidebar. Used to identify and control the sidebar state.
Sidebar content including
Sidebar.Header, Sidebar.Tabs, Sidebar.Tab, etc.Called on sidebar open/close or tab change.Parameters:
state- Current open sidebar state, ornullif closed
Supply alongside
docked prop to make the sidebar user-dockable.Controls whether the sidebar is docked. Must be used with
onDock to enable user docking.Additional CSS class name for styling.
Subcomponents
Sidebar.Header
Header component for the sidebar with title and optional dock/close buttons.Header content (typically a title).
Sidebar.Trigger
Button to open/close the sidebar.Name of the sidebar to trigger (must match the Sidebar’s
name prop).Optional tab name to open when triggering the sidebar.
Icon to display in the trigger button.
Tooltip text for the trigger button.
Additional CSS class name.
Callback when the trigger is clicked.
Inline styles for the trigger button.
Sidebar.Tabs
Container for sidebar tabs.Sidebar.Tab components.Sidebar.Tab
Individual tab content.Unique identifier for the tab.
Tab content.
Sidebar.TabTriggers
Container for tab trigger buttons.Sidebar.TabTrigger components.Sidebar.TabTrigger
Button to switch between tabs.Tab identifier to activate.
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
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
Callback when button is clicked.
Button content (text, icons, etc.).
HTML button type.
Whether button is in active/selected state.
Additional CSS class name for styling.
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
Whether collaboration mode is active.
Callback when the button is clicked.
Editor interface details for responsive behavior.
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
The Excalidraw app instance.
Callback when the stats panel is closed.
Render custom statistics in the panel.
Subcomponents
Stats.StatsRow
Renders a row in the stats panel.Number of columns in the row grid.
Whether this row is a heading.
Stats.StatsRows
Container for multiple stat rows with optional ordering.Display order of this stats group.
Example
DefaultSidebar
TheDefaultSidebar component provides the default sidebar with library and search functionality.
Props
Custom sidebar tabs to add to the default sidebar.
Whether the sidebar is docked.
Callback when sidebar dock state changes. Pass
false to disable docking.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
Content to ellipsify.
All standard HTML span attributes are supported.
Example
TTDDialog
Text-to-Diagram dialog component for AI-powered diagram generation.Props
Callback when text is submitted for diagram generation.
Render custom welcome screen content.
Render custom warning message.
Adapter for persisting chat history.
Subcomponents
TTDDialog.WelcomeMessage
Default welcome message component.Example
TTDDialogTrigger
Trigger button to open the Text-to-Diagram dialog.Props
Custom button label. Defaults to “Text to Diagram”.
Custom icon for the trigger button.
Example
TTDStreamFetch
Utility function for streaming text-to-diagram API responses.Parameters
API endpoint URL for streaming.
Array of messages to send to the LLM.
Callback for each chunk of streamed text.
Whether to extract rate limit headers from the response.
AbortSignal for cancelling the request.
Callback when the stream is created.
Example
DiagramToCodePlugin
Plugin component for adding diagram-to-code conversion functionality.Props
Function to generate code from the diagram.
Example
CommandPalette
Command palette component for quick access to editor actions via keyboard shortcuts.Props
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