Skip to content

The lightweight yet customisable context-menu for your Mantine applications, with a succinct API and dark-theme support. Compatible with Mantine V6.

License

Notifications You must be signed in to change notification settings

icflorescu/mantine-contextmenu-v6

Repository files navigation

Mantine ContextMenu V6

⚠️ Mantine ContextMenu V6 is compatible with Mantine V6.
💡 If you're using Mantine V7, please use Mantine ContextMenu V7.

Publish NPM & deploy docs workflow
NPM version License Stars Last commit Closed issues Downloads Language Sponsor the author

The "dark-theme aware" context-menu for your Mantine UI applications, built by the creator of Mantine DataTable.

Mantine ContextMenu

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, style/styles and sx 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-v6 to view the full documentation and learn how to use it by browsing the list of usage examples.

Quickstart

Install the package and its dependencies:

npm i @mantine/core@6 @mantine/hooks@6 @emotion/react mantine-contextmenu@6

If you're using Next.js, Vite, CRA, Remix or Gatsby, you might need to install additional dependencies. Please refer to Mantine's getting started page for more details.

Wrap your application in the ContextMenuProvider components:

import { MantineProvider } from '@mantine/core';
import { ContextMenuProvider } from 'mantine-contextmenu';

function App() {
  return (
    <MantineProvider>
      <ContextMenuProvider>
        {/* your app code here... */}
      </ContextMenuProvider>
    </MantineProvider>
  );
}

Use the 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

Contributors list

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.

About

The lightweight yet customisable context-menu for your Mantine applications, with a succinct API and dark-theme support. Compatible with Mantine V6.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project