JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q15367F
  • License MIT

Package Exports

  • react-tiny-contextmenu

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-tiny-contextmenu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-tiny-contextmenu

A super tiny, zero dependency context menu.

npm version npm license npm bundle size requires react <16.8 dependencies

API:

target : React.refObject<HtmlElement>
A React ref to attach the context menu to.


items : React.ComponentWithoutRef<'span'>[]
A list of objects representing the context menu's options. Accepts all props that a span would.



children : React.ReactNode
Instead of passing in a list of items, roll your own content.


className : string
ClassNames to be applied to the context menu's container element.


itemClassName : string
ClassNames to be applied to each item element. Applied before any classNames provided per-item.


Usage:

import ContextMenu from "react-tiny-contextmenu"

const contextMenuContainerRef = React.useRef(null)
const items = [
  {
    children: 'One Button',
  },
  {
    children: (
      <div>
        <button>two</button>
        <button>button</button>
      </div>
    ),
  },
  {
    children: 'Red Button',
    className: 'red-button'
  },
  {
    children: 'Blue Button',
    style: { background: 'blue' }
  },
]

...

<span ref={contextMenuContainerRef}>right click me!</span>
<ContextMenu target={contextMenuContainerRef} items={items} />