1.0.3 • Published 8 months ago

@ihatecode/react-context-menu v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@ihatecode/react-context-menu

Englist | 中文

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
PropertyTypeOptional
classNamestringY
zIndexnumberY
contextMenuobjectN
itemsanyN
onClick(key: string) => voidY
ContextMenu Item Props
PropertyTypeOptional
keystringN
labelstringN
iconReactNodeY
disabledbooleanY
childrenanyY

License

MIT

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

1.0.0-alpha.1

8 months ago