Panel

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.

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.


<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.

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.


<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.

Amy Elsner

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 [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.

NameElement
p-panelContainer element.
p-panel-headerHeader section.
p-panel-titleTitle text of panel.
p-panel-header-iconToggle icon.
p-panel-contentContent of panel.

Screen Reader

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.

Content Toggle Button Keyboard Support

KeyFunction
tabMoves focus to the next the focusable element in the page tab sequence.
shift + tabMoves focus to the previous the focusable element in the page tab sequence.
enterToggles the visibility of the content.
spaceToggles the visibility of the content.