MainMenu Component
TheMainMenu component provides a customizable dropdown menu accessed via a hamburger icon. It’s typically positioned in the top-left corner of the editor and contains actions like load, export, help, and custom menu items.
Basic Usage
Props
Menu items and components to display in the dropdown. Can include
MainMenu.Item, MainMenu.ItemLink, MainMenu.DefaultItems.*, MainMenu.Separator, and MainMenu.Group.Callback fired when any menu item is selected (clicked on).
Subcomponents
MainMenu.Item
A clickable menu item that triggers an action.onSelect(function, required) - Callback when item is clickedicon(JSX.Element) - Icon to display before the labelshortcut(string) - Keyboard shortcut to displaychildren(React.ReactNode) - Label content
MainMenu.ItemLink
A menu item that opens a link in a new tab.href(string, required) - URL to openicon(JSX.Element) - Icon to display before the labelshortcut(string) - Keyboard shortcut to displaychildren(React.ReactNode) - Label content
MainMenu.ItemCustom
A fully custom menu item with complete control over rendering.MainMenu.Separator
A visual separator between menu items.MainMenu.Group
Groups related menu items together.MainMenu.Sub
Creates a submenu.MainMenu.Trigger
Custom trigger component to open the menu (overrides default hamburger icon).Default Items
Excalidraw provides pre-built menu items accessible viaMainMenu.DefaultItems:
MainMenu.DefaultItems.LoadScene
Opens a file picker to load a scene from a .excalidraw file.MainMenu.DefaultItems.SaveToActiveFile
Saves the current scene to the active file.MainMenu.DefaultItems.Export
Opens the export dialog to save as PNG, SVG, or JSON.MainMenu.DefaultItems.SaveAsImage
Quickly export the canvas as an image.MainMenu.DefaultItems.Help
Opens the help dialog showing keyboard shortcuts.MainMenu.DefaultItems.ClearCanvas
Clears all elements from the canvas.MainMenu.DefaultItems.ToggleTheme
Toggles between light and dark themes.MainMenu.DefaultItems.ChangeCanvasBackground
Opens a color picker to change the canvas background.Complete Examples
Styling
The MainMenu uses CSS classes that can be targeted for custom styling:.main-menu-trigger- The hamburger icon button.main-menu- The dropdown menu container.main-menu-item- Individual menu items
Best Practices
- Keep it simple - Don’t overcrowd the menu with too many items
- Group related actions - Use
MainMenu.GroupandMainMenu.Separatorfor better organization - Use icons - Icons help users quickly identify actions
- Show shortcuts - Display keyboard shortcuts when available
- Handle mobile - The menu automatically adapts to mobile screens, showing the collaborators list when in collaboration mode
See Also
- Excalidraw - Main component documentation
- WelcomeScreen - Welcome screen customization
- Sidebar - Custom sidebars