Loading...

Context Menu.

import { Menu, ContextMenu } from '@antv/x6-react-components'
import '@antv/x6-react-components/es/menu/style/index.css'
import '@antv/x6-react-components/es/dropdown/style/index.css'
import '@antv/x6-react-components/es/context-menu/style/index.css'
const menu = (
<Menu>
<Menu.Item key="1">1st menu item</Menu.Item>
<Menu.Item key="2">2nd menu item</Menu.Item>
<Menu.Item key="3">3rd menu item</Menu.Item>
</Menu>
)
<ContextMenu menu={menu}>
<div
style={{
width: 560,
height: 240,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
background: '#f5f5f5',
userSelect: 'none',
}}
>
Right Click On Me
</div>
</ContextMenu>

ContextMenu

ParameterDescriptionTypeDefault Value
classNameCustom style namestring-
menuMenu Menu componentMenu-
overlayClassNameClass name for the dropdown root elementstring-
overlayStyleStyle for the dropdown root elementCSSProperties-
disabledWhether the menu is disabledbooleanfalse
visibleWhether the menu is displayedbooleanfalse
getPopupContainerThe parent node for rendering the menu. By default, it renders to the body. If you encounter positioning issues with scrolling, try changing it to the scrolling area and positioning it relative to that.(triggerNode: Element) => HTMLElement-
onVisibleChangeCalled when the visibility state of the menu changes(visible?: boolean) => void-