React Context Menu Component – Customizable Right-Click Menu UI
- Easily integrates with other components for flexible configuration.
- Automatically detects collisions and adjusts submenu positioning using flip-and-fit logic.
- Customization options for menu items, allowing templating and inclusion of additional components like checkboxes, radio buttons, and more.
Trusted by the world’s leading companies
Overview
The React Context Menu is a user interface element that appears upon a right-click or touch-and-hold gesture. It allows you to display menu items, supports nested (multilevel) menus, and allows event handlers to be attached to each item for smooth integration with other components.
React Context Menu code example
Get started with the React Context Menu using a few simple lines of TSX code, as demonstrated below. Also, explore this React Context Menu demo, which shows how to render and configure the Context Menu in React.
import { ContextMenu, MenuItem } from '@syncfusion/react-navigations';
import { useRef } from 'react';
import { CopyIcon, CutIcon} from '@syncfusion/react-icons';
export default function App() {
const targetRef = useRef<HTMLImageElement>(null);
return (
<div className="component-section">
<img ref={targetRef} src={'https://react.syncfusion.com/images/tooltip/mountain.png'} alt="Mountain" className='context-menu-image' />
<ContextMenu targetRef={targetRef as React.RefObject<HTMLElement>}>
<MenuItem text="Cut" icon={<CutIcon />} />
<MenuItem text="Copy" icon={<CopyIcon />} />
</ContextMenu>
</div>
);
};Multilevel menu
The React Context Menu supports multilevel nested items. Submenus can be accessed by hovering over or clicking on menu items. On a desktop, nested items are displayed in multiple layers, while on a mobile device, they appear in a single layer with an option to navigate back to the parent item.
Context menu customization
Icons can be easily included in menu items within the React Context Menu to represent actions visually and enhance user interface clarity. Each element of the menu is customizable, allowing full control over layout, styling, and behavior.
Integration with other components
The React Context Menu can be integrated with any component with simple configurations.
Web accessibility
- Fully supports WAI-ARIA for working with screen readers and assistive devices.
- Follows WAI-ARIA best practices for implementing keyboard interaction.
- Follows WCAG 2.0 standards in the design of UI visual elements such as foreground color, background color, line spacing, text, and images.
- Supports right-to-left (RTL) text rendering for users working in right-to-left languages like Hebrew, Arabic, or Persian.
Not sure how to create your first React Context Menu? Our documentation can help.
I’d love to read it nowPure React Components
Developed using React’s core principles, this library employs functional components and hooks without any external dependencies.
Frequently Asked Questions
Why should you choose the Syncfusion® React Context Menu?
- Easily configurable with other components.
- Automatic collision detection and handling with submenu flip-and-fit.
- Option to customize menu items for templating or include other components like Checkbox, Radio Button, etc.
Simple configuration and APIs.
- Supports all modern browsers.
- Touch-friendly and responsive UI.
Expansive learning demoslet you learn quickly and get started with React Context Menu.
Where can I find the Syncfusion React Context Menu demo?
Find our React Context Menu demo here, which shows you how to render and configure the Context Menu.
Can I download and utilize the Syncfusion React Context Menu for free?
No, this is a commercial product and requires a paid license. However, a free Community License is also available for companies and individuals whose organizations have less than $1 million USD in annual gross revenue, 5 or fewer developers, and 10 or fewer total employees.
How do I get started with the Syncfusion React Context Menu?
A good place to start would be our comprehensive getting started documentation.
Awards
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.