OverlayPanel also known as Popover, is a container component that can overlay other components on page.
import { OverlayPanel } from 'primereact/overlaypanel';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/overlaypanel/overlaypanel.min.js"></script>
OverlayPanel is accessed via its reference where visibility is controlled using toggle, show and hide methods.
<Button type="button" label="Basic" onClick={(e) => op.current.toggle(e)} />
<OverlayPanel ref={op}>
// Content
</OverlayPanel>
Clicking outside the overlay hides the panel, setting dismissable to false disables this behavior. Additionally enablign showCloseIcon property displays a close icon at the top right corner to close the panel.
<OverlayPanel ref={op} showCloseIcon dismissable>
// Content
</OverlayPanel>
OverlayPanel width can be adjusted per screen size with the breakpoints option. In example below, default width is set to 450px and below 961px, width would be 75vw and finally below 641px width becomes 100%. The value of breakpoints should be an object literal whose keys are the maximum screen sizes and values are the widths per screen.
<OverlayPanel ref={op} breakpoints={{'960px': '75vw', '640px': '100vw'}} style={{width: '450px'}}>
// Content
</OverlayPanel>
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
dismissable | boolean | true | Enables to hide the overlay when outside is clicked. |
showCloseIcon | boolean | false | When enabled, displays a close icon at top right corner. |
style | string | null | Inline style of the element. |
className | string | null | Style class of the element. |
appendTo | DOM element | string | document.body | DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located. |
ariaCloseLabel | string | close | Aria label of the close icon. |
breakpoints | object | null | Object literal to define widths per screen size. |
transitionOptions | object | null | The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties. |
Name | Parameters | Description |
---|---|---|
onShow | - | Callback to invoke when overlay becomes visible. |
onHide | - | Callback to invoke when overlay becomes hidden. |
Name | Parameters | Description |
---|---|---|
toggle | event: Browser event | Toggles the visiblity of the overlay. |
show | event: Browser event target: Optional target if event.target should not be used | Shows the overlay. |
hide | - | Hides the overlay. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-overlaypanel | Container element. |
p-overlaypanel-content | Content of the panel. |
p-overlaypanel-close | Close icon. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
None.
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.