Panel is a container component with an optional content toggle feature.
import { PanelModule } from 'primeng/panel';
A simple Panel is created with a header property along with the content as children.
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.
<p-panel header="Header">
<p>
Lorem ipsum dolor sit amet...
</p>
</p-panel>
Content of the panel can be expanded and collapsed using toggleable option, default state is defined with collapsed option. By default, toggle icon is used to toggle the contents whereas setting toggler to "header" enables clicking anywhere in the header to trigger a toggle.
<p-panel header="Header" [toggleable]="true">
<p>
Lorem ipsum dolor sit amet...
</p>
</p-panel>
Header and Footers sections can be customized using header and footer templates.
<p-panel [toggleable]="true">
<ng-template pTemplate="header">
<div class="flex align-items-center gap-2">
<p-avatar
image="https://primefaces.org/cdn/primeng/images/demo/avatar/amyelsner.png"
size="large"
shape="circle" />
<span class="font-bold">
Amy Elsner
</span>
</div>
</ng-template>
<ng-template pTemplate="footer">
<div class="flex flex-wrap align-items-center justify-content-between gap-3">
<div class="flex align-items-center gap-2">
<p-button icon="pi pi-user" rounded="true" text="true" />
<p-button icon="pi pi-bookmark" severity="secondary" rounded="true" text="true" />
</div>
<span class="p-text-secondary">
Updated 2 hours ago
</span>
</div>
</ng-template>
<ng-template pTemplate="icons">
<button class="p-panel-header-icon p-link mr-2" (click)="menu.toggle($event)">
<span class="pi pi-cog"></span>
</button>
<p-menu #menu id="config_menu" [model]="items" [popup]="true" />
</ng-template>
<p class="m-0">
Lorem ipsum dolor sit amet...
</p>
</p-panel>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-panel | Container element. |
p-panel-header | Header section. |
p-panel-title | Title text of panel. |
p-panel-header-icon | 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. |
API defines helper props, events and others for the PrimeNG Panel module.
Panel is a container with the optional content toggle feature.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.
name | parameters | description | |
---|---|---|---|
collapsedChange | value : boolean | Emitted when the collapsed changes. | |
onBeforeToggle | event : PanelBeforeToggleEvent | Callback to invoke before panel toggle. | |
onAfterToggle | event : PanelAfterToggleEvent | Callback to invoke after panel toggle. |
Defines the templates used by the component.
Defines the custom events used by the component's emitters.
Custom panel toggle event, emits before panel toggle.
Custom panel toggle event, emits after panel toggle.