Socket
Socket
Sign inDemoInstall

chakra-ui-contextmenu

Package Overview
Dependencies
186
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chakra-ui-contextmenu

Context Menu component for Chakra UI


Version published
Weekly downloads
1.2K
increased by28.32%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 27 Oct 2022

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc