Socket
Book a DemoInstallSign in
Socket

chakra-ui-contextmenu

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chakra-ui-contextmenu

Context Menu component for Chakra UI

1.0.5
latest
Source
npmnpm
Version published
Weekly downloads
262
-50.84%
Maintainers
1
Weekly downloads
 
Created
Source

chakra-ui-contextmenu

Context Menu component for Chakra UI

Demo for React Complex Tree

Checkout the storybook for more examples!

Installation

To start using chakra-ui-contextmenu, install it to your project as a dependency via

npm install chakra-ui-contextmenu

then import it and add your context menu component with

import { ContextMenu } from 'chakra-ui-contextmenu';
import { Box, Button, ChakraProvider } from '@chakra-ui/react';
import { MenuList, MenuItem } from '@chakra-ui/menu';

render(
  <ContextMenu
    renderMenu={() => (
      <MenuList>
        <MenuItem>Context Menu Item 1</MenuItem>
        <MenuItem>Context Menu Item 2</MenuItem>
      </MenuList>
    )}
  >
    {ref => <div ref={ref}>Target</div>}
  </ContextMenu>
);

Usage with Typescript

When using Typescript, you can type the context menu component with the kind of target component to get better typings:

render(
  <ContextMenu<HTMLDivElement>
    renderMenu={() => (
      <MenuList>
        <MenuItem>Context Menu Item 1</MenuItem>
        <MenuItem>Context Menu Item 2</MenuItem>
      </MenuList>
    )}
  >
    {ref => <div ref={ref}>Target</div>}
  </ContextMenu>
);

Props

The ContextMenu component provides the following props:

export interface ContextMenuProps<T extends HTMLElement> {
  renderMenu: () => JSX.Element | null;
  children: (ref: MutableRefObject<T | null>) => JSX.Element | null;
  menuProps?: MenuProps;
  portalProps?: PortalProps;
  menuButtonProps?: MenuButtonProps;
}

Keywords

react

FAQs

Package last updated on 27 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.