Package Exports
- mantine-contextmenu
- mantine-contextmenu/styles.css
- mantine-contextmenu/styles.layer.css
Readme
Mantine ContextMenu
The "dark-theme aware" context-menu for your Mantine UI applications, built by the creator of Mantine DataTable.
⚠️ NOTE: Mantine ContextMenu V7 is compatible with Mantine V7.
💡 If you're looking for an older version that works with Mantine V6, head over to Mantine ContextMenu V6.
Features
- Lightweight - no external dependencies, no bloat
- Dark-theme aware - automatically adapts to the current Mantine theme
- Simple API - just wrap your application in the
ContextMenuProvider
component and use the hook-generated function in your code - Custom content support - use any Mantine component as context menu content
- Highly customizable styling - use the
className
/classNames
andstyle
/styles
props to customize the context menu appearance - Written in Typescript and well-documented - with detailed JSDoc annotations for each exported function and component
Full documentation and examples
Visit icflorescu.github.io/mantine-contextmenu to view the full documentation and learn how to use it by browsing the list of usage examples.
Quickstart
Create a new Mantine application, make sure to have the clsx
peer dependency installed,
then install the package with npm i mantine-contextmenu
or yarn add mantine-contextmenu
:
Wrap your application in a ContextMenuProvider
inside the MantineProvider
and don't forget to import the necessary CSS files in the correct order (you might need to use CSS layers):
import { MantineProvider } from '@mantine/core';
import { ContextMenuProvider } from 'mantine-contextmenu';
// 👇 Mantine core first
import '@mantine/core/styles.css';
// 👇 Mantine context menu second
import 'mantine-contextmenu/styles.css';
function App() {
return (
<MantineProvider>
<ContextMenuProvider>{/* your app code here... */}</ContextMenuProvider>
</MantineProvider>
);
}
Use the showContextMenu
hook-generated function in your code:
import { IconCopy, IconDownload } from '@tabler/icons-react';
import { useContextMenu } from 'mantine-contextmenu';
import Picture from '~/components/Picture';
import { copyImageToClipboard, downloadImage, unsplashImages } from '~/lib/image';
export default function GettingStartedExample() {
const showContextMenu = useContextMenu();
const image = unsplashImages[0];
const { src } = image.file;
return (
<Picture
image={image}
onContextMenu={showContextMenu([
{
key: 'copy',
icon: <IconCopy size={16} />,
title: 'Copy to clipboard',
onClick: () => copyImageToClipboard(src),
},
{
key: 'download',
icon: <IconDownload size={16} />,
title: 'Download to your computer',
onClick: () => downloadImage(src),
},
])}
/>
);
}
Make sure to browse the list of usage examples to learn how to unleash the full power of Mantine ContextMenu.
Other useful resources
💡 Mantine DataTable - The "dark-theme aware" data-table component for your Mantine UI applications, built by the creator of Mantine ContextMenu.
Code contributors
Want to become a code contributor?
Sponsor the project
If you find this package useful, please consider ❤️ sponsoring my work. Your sponsorship will help me dedicate more time to maintaining the project and will encourage me to add new features and fix existing bugs. If you're a company using Mantine ContextMenu in a commercial project, you can also hire my services.
Other means of support
If you find this package useful, please 🙏 star the repository, 💕 tweet about it, 👍 endorse me on LinkedIn or consider hiring my services.
The more stars this repository gets, the more visibility it gains among the Mantine users community. The more users it gets, the more chances that some of those users will become active code contributors willing to put their effort into bringing new features to life and/or fixing bugs.
As the repository gain awareness, my chances of getting hired to work on Mantine-based projects will increase, which in turn will help maintain my vested interest in keeping the project alive.
Hiring the author
If you want to hire my services, don’t hesitate to drop me a line at the email address listed in my GitHub profile. I’m currently getting a constant flow of approaches, some of them relevant, others not so relevant. Mentioning “Mantine ContextMenu” in your text would help me prioritize your message.
License
The MIT License.