logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Popper

A Popper enables the display of content overlaid on another element, serving as an alternative to react-popper.

Key characteristics of the Popper component include:
  • 🕷 The Popper depends on the third-party library (Popper.js) for precise positioning.
  • 💄 It provides a simpler API compared to react-popper, prioritizing ease of use.
  • Its child element utilizes a MUI Base Portal on the document body to prevent rendering issues. This can be disabled using the disablePortal prop.
  • Unlike the Popover component, the scroll remains unblocked, and the popper’s placement adjusts dynamically to the available viewport space.
  • Clicking outside does not hide the Popper. For this functionality, consider using the MUI Base Click-Away Listener, as shown in the menu documentation section.
  • The anchorEl prop is used as the reference object to initialize a new Popper.js instance.

Basic Popper

Transitions

The popper’s open/close state can be animated using a render prop child combined with a transition component. This component must adhere to these requirements:
  • Be a direct child of the popper.
  • Invoke the onEnter callback when the enter transition begins.
  • Invoke the onExited callback upon completion of the exit transition, allowing the popper to unmount the child content when closed and fully transitioned.
The Popper includes built-in support for react-transition-group.
For an alternative you can leverage react spring.

Positioned popper



Scroll playground

Virtual element

The anchorEl prop can reference a virtual DOM element. You must create an object conforming to the VirtualElement structure.
Select a portion of the text to display the popper:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ipsum purus, bibendum sit amet vulputate eget, porta semper ligula. Donec bibendum vulputate erat, ac fringilla mi finibus nec. Donec ac dolor sed dolor porttitor blandit vel vel purus. Fusce vel malesuada ligula. Nam quis vehicula ante, eu finibus est. Proin ullamcorper fermentum orci, quis finibus massa. Nunc lobortis, massa ut rutrum ultrices, metus metus finibus ex, sit amet facilisis neque enim sed neque. Quisque accumsan metus vel maximus consequat. Suspendisse lacinia tellus a libero volutpat maximus.

Supplementary projects

For advanced scenarios, you may benefit from the following resources:

material-ui-popup-state

starsnpm downloads
The material-ui-popup-state package simplifies managing popper state in most use cases.