import OverlayPanel from 'primevue/overlaypanel';
<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
<script src="https://unpkg.com/primevue@^3/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="Toggle" @click="toggle" />
<OverlayPanel ref="op">
<img src="/demo/images/nature/nature1.jpg" alt="Nature Image">
</OverlayPanel>
toggle(event) {
this.$refs.op.toggle(event);
}
Clicking outside the overlay hides the panel, setting dismissable to false disables this behavior. Additionally enabling showCloseIcon property displays a close icon at the top right corner to close the panel.
<OverlayPanel ref="op" :showCloseIcon="true" :dismissable="true">
<img src="/demo/images/nature/nature1.jpg" alt="Nature Image">
</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 |
---|---|---|---|
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. |
appendTo | string | body | A valid query selector or an HTMLElement to specify where the overlay gets attached. |
baseZIndex | number | 0 | Base zIndex value to use in layering. |
autoZIndex | boolean | true | Whether to automatically manage layering. |
ariaCloseLabel | string | close | Aria label of the close icon. |
breakpoints | object | null | Object literal to define widths per screen size. |
Name | Parameters | Description |
---|---|---|
toggle |
event: Browser event target: Optional target if event.currentTarget should not be used |
Toggles the visibility of the overlay. |
show |
event: Browser event target: Optional target if event.currentTarget should not be used |
Shows the overlay. |
hide | - | Hides the overlay. |
Name | Parameters | Description |
---|---|---|
show | - | Callback to invoke when the overlay is shown. |
hide | - | Callback to invoke when the overlay is hidden. |
Following is the list of structural style classes, for theming classes visit
Name | Element |
---|---|
p-overlaypanel | Container element. |
p-overlaypanel-content | Content of the panel. |
p-overlaypanel-close | Close icon. |
None.