DevExtreme React - Overview

The ContextMenu widget displays a single- or multi-level context menu. An end user invokes this menu by a right click or a long press.

View Demo

The following code adds the ContextMenu widget to your page and binds it to an image using the target option. Note that the data source of the widget declares several nesting levels. Items in the resulting context menu mirror this structure.

App.js
  • import React from 'react';
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { ContextMenu } from 'devextreme-react/context-menu';
  •  
  • const contextMenuItems = [
  • { text: 'Zoom In' },
  • { text: 'Zoom Out' },
  • {
  • text: 'Share',
  • items: [{
  • text: 'Send to a friend',
  • items: [
  • { text: 'Log in with Facebook' },
  • { text: 'Log in with Twitter' }
  • ]
  • }, {
  • text: 'Send to a group',
  • items: [
  • { text: 'Log in with Facebook' },
  • { text: 'Log in with Twitter' }
  • ]
  • }]
  • },
  • { text: 'Comment' }
  • ];
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <div>
  • <img id="someImage" src="http://here/goes/my.jpg" />
  • <ContextMenu
  • items={contextMenuItems}
  • target="#someImage"
  • />
  • </div>
  • );
  • }
  • }
  •  
  • export default App;
See Also