🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

material-ui-popup-state

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

material-ui-popup-state

easiest way to create menus, popovers, and poppers with material-ui

5.3.6
latest
Version published
Weekly downloads
263K
2.42%
Maintainers
1
Weekly downloads
 
Created

What is material-ui-popup-state?

The material-ui-popup-state npm package provides utilities to manage the state of Material-UI popups such as menus, popovers, and tooltips. It simplifies the process of handling open/close state, anchor elements, and other common popup behaviors.

What are material-ui-popup-state's main functionalities?

Menu Popup

This feature allows you to create a menu popup that can be triggered by a button. The PopupState component manages the state of the popup, and the bindTrigger and bindMenu functions are used to bind the popup state to the button and menu components respectively.

```jsx
import React from 'react';
import { Button, Menu, MenuItem } from '@material-ui/core';
import PopupState, { bindTrigger, bindMenu } from 'material-ui-popup-state';

function MenuPopup() {
  return (
    <PopupState variant="popover" popupId="demoMenu">
      {(popupState) => (
        <React.Fragment>
          <Button variant="contained" color="primary" {...bindTrigger(popupState)}>
            Open Menu
          </Button>
          <Menu {...bindMenu(popupState)}>
            <MenuItem onClick={popupState.close}>Option 1</MenuItem>
            <MenuItem onClick={popupState.close}>Option 2</MenuItem>
            <MenuItem onClick={popupState.close}>Option 3</MenuItem>
          </Menu>
        </React.Fragment>
      )}
    </PopupState>
  );
}

export default MenuPopup;
```

Popover Popup

This feature allows you to create a popover popup that can be triggered by a button. The PopupState component manages the state of the popover, and the bindTrigger and bindPopover functions are used to bind the popup state to the button and popover components respectively.

```jsx
import React from 'react';
import { Button, Popover, Typography } from '@material-ui/core';
import PopupState, { bindTrigger, bindPopover } from 'material-ui-popup-state';

function PopoverPopup() {
  return (
    <PopupState variant="popover" popupId="demoPopover">
      {(popupState) => (
        <React.Fragment>
          <Button variant="contained" color="primary" {...bindTrigger(popupState)}>
            Open Popover
          </Button>
          <Popover
            {...bindPopover(popupState)}
            anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
            transformOrigin={{ vertical: 'top', horizontal: 'center' }}
          >
            <Typography>The content of the Popover.</Typography>
          </Popover>
        </React.Fragment>
      )}
    </PopupState>
  );
}

export default PopoverPopup;
```

Tooltip Popup

This feature allows you to create a tooltip popup that can be triggered by hovering or focusing on a button. The PopupState component manages the state of the tooltip, and the bindTrigger and bindTooltip functions are used to bind the popup state to the button and tooltip components respectively.

```jsx
import React from 'react';
import { Button, Tooltip } from '@material-ui/core';
import PopupState, { bindTrigger, bindTooltip } from 'material-ui-popup-state';

function TooltipPopup() {
  return (
    <PopupState variant="tooltip" popupId="demoTooltip">
      {(popupState) => (
        <Tooltip {...bindTooltip(popupState)} title="Tooltip text">
          <Button variant="contained" color="primary" {...bindTrigger(popupState)}>
            Hover or Focus
          </Button>
        </Tooltip>
      )}
    </PopupState>
  );
}

export default TooltipPopup;
```

Other packages similar to material-ui-popup-state

FAQs

Package last updated on 12 May 2025

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