Popover API
The API documentation of the Popover React component. Learn more about the props and the CSS customization points.
Import
import Popover from '@material-ui/core/Popover';
// or
import { Popover } from '@material-ui/core';
You can learn more about the difference by reading this guide.
Component name
The MuiPopover
name can be used for providing default props or style overrides at the theme level.
Props
Name | Type | Default | Description |
---|---|---|---|
action | ref | A ref for imperative actions. It currently only supports updatePosition() action. | |
anchorEl | HTML element | func |
A HTML element, or a function that returns it. It's used to set the position of the popover. | |
anchorOrigin | { horizontal: 'center' | 'left' | 'right' | number, vertical: 'bottom' | 'center' | 'top' | number } |
{ vertical: 'top', horizontal: 'left',} | This is the point on the anchor where the popover's anchorEl will attach to. This is not used when the anchorReference is 'anchorPosition'.Options: vertical: [top, center, bottom]; horizontal: [left, center, right]. |
anchorPosition | { left: number, top: number } | This is the position that may be used to set the position of the popover. The coordinates are relative to the application's client area. | |
anchorReference | 'anchorEl' | 'anchorPosition' | 'none' |
'anchorEl' | This determines which anchor prop to refer to to set the position of the popover. |
children | node | The content of the component. | |
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
container | HTML element | React.Component | func |
A HTML element, component instance, or function that returns either. The container will passed to the Modal component.By default, it uses the body of the anchorEl's top-level document object, so it's simply document.body most of the time. |
|
elevation | number | 8 | The elevation of the popover. |
getContentAnchorEl | func | This function is called in order to retrieve the content anchor element. It's the opposite of the anchorEl prop. The content anchor element should be an element inside the popover. It's used to correctly scroll and set the position of the popover. The positioning strategy tries to make the content anchor element just above the anchor element. |
|
marginThreshold | number | 16 | Specifies how close to the edge of the window the popover can appear. |
onClose | func | Callback fired when the component requests to be closed. | |
onEnter | func | Callback fired before the component is entering. | |
onEntered | func | Callback fired when the component has entered. | |
onEntering | func | Callback fired when the component is entering. | |
onExit | func | Callback fired before the component is exiting. | |
onExited | func | Callback fired when the component has exited. | |
onExiting | func | Callback fired when the component is exiting. | |
open * | bool | If true , the popover is visible. |
|
PaperProps | { component?: element type } | {} | Props applied to the Paper element. |
transformOrigin | { horizontal: 'center' | 'left' | 'right' | number, vertical: 'bottom' | 'center' | 'top' | number } |
{ vertical: 'top', horizontal: 'left',} | This is the point on the popover which will attach to the anchor's origin. Options: vertical: [top, center, bottom, x(px)]; horizontal: [left, center, right, x(px)]. |
TransitionComponent | elementType | Grow | The component used for the transition. Follow this guide to learn more about the requirements for this component. |
transitionDuration | 'auto' | number | { appear?: number, enter?: number, exit?: number } |
'auto' | Set to 'auto' to automatically calculate transition time based on height. |
TransitionProps | object | {} | Props applied to the Transition element. |
The ref
is forwarded to the root element.
Any other props supplied will be provided to the root element (Modal).
CSS
Rule name | Global class | Description |
---|---|---|
root | .MuiPopover-root | Styles applied to the root element. |
paper | .MuiPopover-paper | Styles applied to the Paper component. |
You can override the style of the component thanks to one of these customization points:
- With a rule name of the
classes
object prop. - With a global class name.
- With a theme and an
overrides
property.
If that's not sufficient, you can check the implementation of the component for more detail.
Inheritance
The props of the Modal component are also available. You can take advantage of this behavior to target nested components.