Skip to content

rebelchris/react-contexify

This branch is 1 commit ahead of, 72 commits behind fkhadra/react-contexify:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1eac8d9 · Nov 2, 2021
Dec 9, 2020
Nov 13, 2020
Nov 14, 2020
Oct 26, 2020
Nov 29, 2020
Nov 2, 2021
Oct 6, 2020
Oct 26, 2020
Oct 26, 2020
Oct 6, 2020
Jan 21, 2021
Oct 26, 2020
Nov 30, 2020
Oct 6, 2020
Nov 8, 2020

Repository files navigation

screenshot 2018-10-31 at 13 32 57

React-contexify CI npm npm license

Documentation

Go here.

Installation

Using yarn

$ yarn add react-contexify

Using npm

$ npm install --save react-contexify

The gist

import React from 'react';
import { Menu, Item, Separator, Submenu, MenuProvider, useContextMenu } from 'react-contexify';
import 'react-contexify/dist/ReactContexify.css';

const MENU_ID = 'blahblah';

function App() {
  const { show } = useContextMenu({
    id: MENU_ID,
  });

  function handleContextMenu(event){
      event.preventDefault();
      show(event, {
        props: {
            key: 'value'
        }
      })
  }
  const handleItemClick = ({ event, props }) => console.log(event,props);

  return (
    <div>
    <p onContextMenu={handleContextMenu}>lorem ipsum blabladhasi blaghs blah</p>  
    <Menu id={MENU_ID}>
      <Item onClick={handleItemClick}>Item 1</Item>
      <Item onClick={handleItemClick}>Item 2</Item>
      <Separator />
      <Item disabled>Disabled</Item>
      <Separator />
      <Submenu label="Foobar">
        <Item onClick={handleItemClick}>Sub Item 1</Item>
        <Item onClick={handleItemClick}>Sub Item 2</Item>
      </Submenu>
    </Menu>
    </div>
  );
}

Contribute

Any idea and suggestions are welcome. Please have a look at the contributing guide.

License

React Contexify is licensed under MIT.

About

Add a context menu to your react app with ease

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 87.0%
  • SCSS 8.8%
  • JavaScript 2.7%
  • Other 1.5%