A Popover can be used to display some content on top of another.
Things to know when using the Popover
component:
Modal
component.Popper
component.{{ādemoā: āBasicPopover.jsā}}
Use the radio buttons to adjust the anchorOrigin
and transformOrigin
positions.
You can also set the anchorReference
to anchorPosition
or anchorEl
.
When it is anchorPosition
, the component will, instead of anchorEl
,
refer to the anchorPosition
prop which you can adjust to set
the position of the popover.
{{ādemoā: āAnchorPlayground.jsā, āhideToolbarā: true}}
This demo demonstrates how to use the Popover
component with mouseenter
and mouseleave
events to achieve popover behavior.
{{ādemoā: āMouseHoverPopover.jsā}}
The value of the anchorEl
prop can be a reference to a fake DOM element.
You need to provide an object with the following interface:
interface PopoverVirtualElement {
nodeType: 1;
getBoundingClientRect: () => DOMRect;
}
Highlight part of the text to see the popover:
{{ādemoā: āVirtualElementPopover.jsā}}
For more information on the virtual elementās properties, see the following resources:
The usage of a virtual element for the Popover component requires the
nodeType
property. This is different from virtual elements used for thePopper
orTooltip
components, both of which donāt require the property.
For more advanced use cases, you might be able to take advantage of:
The package material-ui-popup-state
that takes care of popover state for you in most cases.
{{ādemoā: āPopoverPopupState.jsā}}