Skip to main content

MainMenu

By default Excalidraw will render the MainMenu with default options. If you want to customise the MainMenu, you can pass the MainMenu component with the list options.

Usage

Live Editor
Result
Loading...

This is the MainMenu component. If you render it, you will need to populate the menu with your own items as we will not render any ourselves at that point.

PropTypeRequiredDefaultDescription
onSelectfunctionNo-Triggered when any item is selected (via mouse). Calling event.preventDefault() will stop menu from closing.

To render an item, its recommended to use MainMenu.Item.

PropTypeRequiredDefaultDescription
onSelectfunctionYes-Triggered when selected (via mouse). Calling event.preventDefault() will stop menu from closing.
selectedbooleanNofalseWhether item is active
childrenReact.ReactNodeYes-The content of the menu item
iconJSX.ElementNo-The icon used in the menu item
shortcutstringNo-The shortcut to be shown for the menu item

To render an item as a link, its recommended to use MainMenu.ItemLink.

Usage

Live Editor
Result
Loading...
PropTypeRequiredDefaultDescription
onSelectfunctionNo-Triggered when selected (via mouse). Calling event.preventDefault() will stop menu from closing.
selectedbooleanNofalseWhether item is active
hrefstringYes-The href attribute to be added to the anchor element.
childrenReact.ReactNodeYes-The content of the menu item
iconJSX.ElementNo-The icon used in the menu item
shortcutstringNo-The shortcut to be shown for the menu item

To render a custom item, you can use MainMenu.ItemCustom.

Usage

Live Editor
Result
Loading...
PropTypeRequiredDefaultDescription
childrenReact.ReactNodeYes-The content of the menu item

For the items which are shown in the menu in excalidraw.com, you can use MainMenu.DefaultItems

Live Editor
Result
Loading...

Here is a complete list of the default items.

To Group item in the main menu, you can use MainMenu.Group

Live Editor
Result
Loading...
PropTypeRequiredDefaultDescription
children React.ReactNodeYes-The content of the Menu Group