import Panel from 'primevue/panel';
<script src="https://unpkg.com/primevue@^3/core/core.min.js"></script>
<script src="https://unpkg.com/primevue@^3/panel/panel.min.js"></script>
Panel is a container component that accepts content as its children.
<Panel header="Header">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Panel>
Header of the panel is either defined with the header property or the header template.
<Panel>
<template #header>
Header Content
</template>
Content
</Panel>
Content of the panel can be expanded and collapsed using toggleable option.
<Panel header="Header" :toggleable="true">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Panel>
To control the initial state of the toggleable panel, use the collapsed property.
<Panel header="Header Text" :toggleable="true" :collapsed="true">
Content
</Panel>
Use the v-model directive to enable two-way binding.
<button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically</button>
<Panel header="Header Text" :toggleable="true" v-model:collapsed="isCollapsed">
Content
</Panel>
Additional icons can be placed at the header section of the panel using the special icons slot. For a unified look, it is suggest to add .p-panel-header-icon class to your icons.
<h5>Advanced</h5>
<Panel header="Header">
<template #icons>
<button class="p-panel-header-icon p-link mr-2" @click="toggle">
<span class="pi pi-cog"></span>
</button>
<Menu id="config_menu" ref="menu" :model="items" :popup="true" />
</template>
</Panel>
Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
Name | Type | Default | Description |
---|---|---|---|
header | string | null | Header text of the panel. |
toggleable | boolean | null | Defines if content of panel can be expanded and collapsed. |
collapsed | boolean | null | Defines the initial state of panel content. |
toggleButtonProps | string | null | Uses to pass the custom value to read for the button inside the component. |
Name | Parameters | Description |
---|---|---|
toggle |
event.originalEvent: browser event event.value: collapsed state as a boolean |
Callback to invoke when a tab toggle. |
Name | Parameters |
---|---|
header | - |
icons | - |
Following is the list of structural style classes, for theming classes visit
Name | Element |
---|---|
p-panel | Container element. |
p-panel-header | Header section. |
p-panel-title | Title text of panel. |
p-panel-header-icon | Action icons inside header. |
p-panel-toggler | Toggle icon. |
p-panel-content | Content of panel. |
Toggleable panels use a content toggle button at the header that has aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read the button defaults to the value of the header property and can be customized by defining an aria-label or aria-labelledby via the toggleButtonProps property.
The content uses region, defines an id that matches the aria-controls of the content toggle button and aria-labelledby referring to the id of the header.
Key | Function |
---|---|
tab | Moves focus to the next the focusable element in the page tab sequence. |
shift + tab | Moves focus to the previous the focusable element in the page tab sequence. |
enter | Toggles the visibility of the content. |
space | Toggles the visibility of the content. |
None.