UNPKG

1.35 kBMarkdownView Raw
1[npm]: https://img.shields.io/npm/v/@asup/context-menu
2[npm-url]: https://www.npmjs.com/package/@asup/context-menu
3[size]: https://packagephobia.now.sh/badge?p=@asup/context-menu
4[size-url]: https://packagephobia.now.sh/result?p=@asup/context-menu
5
6[![npm][npm]][npm-url]
7[![size][size]][size-url]
8![npm bundle size](https://img.shields.io/bundlephobia/min/@asup/context-menu)
9[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/PaulDThomas/context-menu/master/LICENCE)
10
11# @asup/context-menu
12
13REACT Context menu, because I couldn't quite find what I wanted.
14
15## Installation
16
17```
18# with npm
19npm install @asup/context-menu
20```
21
22## Usage
23
24Context menu provider, takes a list of available actions and renders a context menu on appropriate click.
25Sub menus can be added within each item.
26Wrap around the elements that need to have the menu.
27
28```
29import { ContextMenuProvider, iMenuItem } from '@asup/context-menu';
30
31<ContextMenuHandler
32 menuItems={[
33 { label: 'Item 1', action: item1Function },
34 { label: 'Item 2', action: item2Function, group: [
35 { label: 'Subitem 2.1', action: item21Function }
36 ...
37 ]
38 },
39 { label: 'Item 3', action: item3Function, disabeld: true },
40 ...
41 ]}
42>
43 <Chilren
44 where the context menu is applied...
45 />
46</ContextMenuProvider>
47```