@ihatecode/react-context-menu
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@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

Package Sidebar

Install

npm i @ihatecode/react-context-menu

Weekly Downloads

62,998

Version

1.0.3

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • zctcode