Loading...

Menu component. Generally used in Menubar, ContextMenu, and Dropdown components.

import { Menu } from '@antv/x6-react-components'
import '@antv/x6-react-components/es/menu/style/index.css'
const MenuItem = Menu.Item
const SubMenu = Menu.SubMenu
const Divider = Menu.Divider
<Menu hasIcon={true} onClick={this.onMenuClick}>
<MenuItem onClick={this.onMenuItemClick} name="undo" icon={<UndoOutlined />} hotkey="Cmd+Z" text="Undo" />
<MenuItem name="redo" icon={<RedoOutlined />} hotkey="Cmd+Shift+Z" text="Redo" />
<Divider />
<MenuItem name="cut" icon={<ScissorOutlined />} hotkey="Cmd+X" text="Cut" />
<MenuItem name="copy" icon={<CopyOutlined />} hotkey="Cmd+C" text="Copy" />
<MenuItem name="paste" icon={<SnippetsOutlined />} hotkey="Cmd+V" disabled={true} text="Paste" />
<MenuItem name="delete" icon={<DeleteOutlined />} hotkey="Delete" text="Delete" />
<Divider />
<SubMenu text="Appearance" icon={<ControlOutlined />}>
<MenuItem name="zen" icon={<DesktopOutlined />} hotkey="Cmd+K Z" text="Zen Mode" />
<MenuItem name="fullscreen" icon={<FullscreenOutlined />} hotkey="Cmd+Shift+F" text="Full Screen" />
<Divider />
<MenuItem name="side-bar" text="Show Side Bar" />
<MenuItem name="status-bar" text="Show Status Bar" />
<MenuItem name="activity-bar" text="Show Activity Bar" />
<MenuItem name="editor-area" text="Show Editor Area" />
<MenuItem name="show-panel" text="Show Panel" />
</SubMenu>
</Menu>

Menu

ParameterDescriptionTypeDefault Value
classNameCustom style namestring-
hasIconWhether to include an Iconbooleanfalse
onClickFunction called when MenuItem is clicked(name: string) => void-
registerHotkeyRegister a hotkey(hotkey: string, handler: () => void) => void-
unregisterHotkeyUnregister a hotkey(hotkey: string, handler: () => void) => void-

Menu.Item

ParameterDescriptionTypeDefault Value
classNameCustom style namestring-
nameMenu name (unique identifier), used in the Menu's onClick callback. If the name attribute is not set, onClick will not be called.string-
iconMenu iconReactNode-
textMenu textstring-
hotkeyMenu hotkeystring-
activeWhether it is active (shows background on mouse hover)booleanfalse
hiddenWhether it is hiddenbooleanfalse
disabledWhether it is disabledbooleanfalse
onClickFunction called when MenuItem is clicked() => void-
childrenAdditional child componentsReactNode-

Menu.SubMenu

ParameterDescriptionTypeDefault Value
classNameCustom style namestring-
nameMenu name (unique identifier), used in the Menu's onClick callbackstring-
iconMenu iconReactNode-
textMenu textstring-
hotkeyMenu hotkeystring-
activeWhether it is active (shows background on mouse hover and sub-menu)booleanfalse
hiddenWhether it is hiddenbooleanfalse
disabledWhether it is disabledbooleanfalse
onClickFunction called when MenuItem is clicked() => void-

Menu.Divider

Menu item divider.