Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ihatecode/react-context-menu

zctcode26MIT1.0.3TypeScript support: included

A context menu component written in React.

ihatecode, react, context-menu, react-context-menu

readme

@ihatecode/react-context-menu

Englist | 中文

npm npm GitHub forks GitHub Repo stars

Introduction

A context menu component written in React.

Install

# npm
npm install @ihatecode/react-context-menu
# yarn
yarn add @ihatecode/react-context-menu
# pnpm
pnpm add @ihatecode/react-context-menu

Usage

import React from 'react';
import ContextMenu from '@ihatecode/react-context-menu';
import '@ihatecode/react-context-menu/lib/style.css';

const App: React.FC = () => {
  const [contextMenu] = ContextMenu.useContextMenu();

  return (
    <div style={{ width:'100vw', height:'100vh'}}>
      <div style={{ width:'100%', height:'100%'}} onContextMenu={contextMenu.onContextMenu}></div>
        <ContextMenu
          contextMenu={contextMenu}
          items={[{ key:'1', label: 'item1' }, { key:'2', label: 'item2' }]}
          onClick={(key) => console.log(key)}
        />
    </div>
  );
};

export default App;

Demo

Online demo: https://q5fknh.csb.app/

Edit react-splitter

Props

ContextMenu Props
Property Type Optional
className string Y
zIndex number Y
contextMenu object N
items any N
onClick (key: string) => void Y
ContextMenu Item Props
Property Type Optional
key string N
label string N
icon ReactNode Y
disabled boolean Y
children any Y

License

MIT