Skip to main content

MainMenu Component

The MainMenu 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

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

Subcomponents

A clickable menu item that triggers an action.
Props:
  • onSelect (function, required) - Callback when item is clicked
  • icon (JSX.Element) - Icon to display before the label
  • shortcut (string) - Keyboard shortcut to display
  • children (React.ReactNode) - Label content
A menu item that opens a link in a new tab.
Props:
  • href (string, required) - URL to open
  • icon (JSX.Element) - Icon to display before the label
  • shortcut (string) - Keyboard shortcut to display
  • children (React.ReactNode) - Label content
A fully custom menu item with complete control over rendering.
A visual separator between menu items.
Groups related menu items together.
Creates a submenu.
Custom trigger component to open the menu (overrides default hamburger icon).

Default Items

Excalidraw provides pre-built menu items accessible via MainMenu.DefaultItems: Opens a file picker to load a scene from a .excalidraw file.
Saves the current scene to the active file.
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.

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

  1. Keep it simple - Don’t overcrowd the menu with too many items
  2. Group related actions - Use MainMenu.Group and MainMenu.Separator for better organization
  3. Use icons - Icons help users quickly identify actions
  4. Show shortcuts - Display keyboard shortcuts when available
  5. Handle mobile - The menu automatically adapts to mobile screens, showing the collaborators list when in collaboration mode

See Also