Switch theme

Examples › Basic configuration

The ContextMenuProvider component accepts the following props that are used as default values for the context menu container:
<MantineProvider>
<ContextMenuProvider zIndex={1000} shadow="md" borderRadius="md">
<Component {...pageProps} />
</ContextMenuProvider>
</MantineProvider>
These props are used as default values for the context menu and you can override them by passing the same props as the second argument to the showContextMenu function returned by the useContextMenu hook:
const showContextMenu = useContextMenu();
// ...
return (
<Picture
image={image}
onContextMenu={showContextMenu(
[
{
key: 'copy',
onClick: () => copyImageToClipboard(src),
},
{
key: 'download',
onClick: () => downloadImage(src),
},
],
{ zIndex: 1000, shadow: 'md', borderRadius: 'md' }
)}
/>
);
Right-click on the image to trigger the context menu:
Picture by Michael Sum | Mantine ContextMenu
Picture by Michael Sum
MIT LicenseSponsor the author
Built by Ionut-Cristian Florescu, the author of Mantine DataTable.
Please sponsor my work if you find it useful.
GitHub StarsNPM Downloads