Popover API
导入
import Popover from '@mui/material/Popover';
// 或
import { Popover } from '@mui/material';
组件名称
在主题中,名称“MuiPopover
”可用于提供默认属性(props),或者样式覆盖属性
Modal 组件的属性也是可用的。
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
open* | bool | false | Control the popup` open state. |
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 | 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 | integer | 8 | The elevation of the popover. |
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. The reason parameter can optionally be used to control the response to onClose . | |
PaperProps | { component?: element type } | {} | Props applied to the Paper element. |
sx | Array<func | object | bool> | func | object | The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details. | |
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. By default, the element is based on this Transition component. |
ref
则会被传递到根元素中。继承
尽管上文没有明文记录, Modal 组件 的属性(props) 在组件Popover上同样是可用的。 你可以利用这一点来 指向嵌套组件CSS
规则名称 | 全局类名 | 描述 |
---|---|---|
root | .MuiPopover-root | Styles applied to the root element. |
paper | .MuiPopover-paper | Styles applied to the Paper component. |
您可以使用组件自定义选项对组件进行个性化:
- 具备 全局类名.
- 在自定义主体中,设定一个规则名称作为组件的
styleOverrides
属性的一部分。