PanelPanel is a grouping component with the optional content toggle feature.
Documentation
Import
import {PanelModule} from 'primeng/panel';
Getting Started
Panel is defined with p-panel element.
<p-panel header="Title">
Content
</p-panel>
Toggleable
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="Title" [toggleable]="true">
Content
</p-panel>
Header and Footer Content
Header and Footers sections can be customized using p-header and p-footer components.
<p-panel >
<p-header>
Header content here
</p-header>
Body Content
<p-footer>
Footer content here
</p-footer>
</p-panel>
Animation Configuration
Transition of the toggle animation can be customized using the transitionOptions property with a default value as 400ms cubic-bezier(0.86, 0, 0.07, 1), example below disables the animation altogether.
<p-panel [transitionOptions]="'0ms'">
</p-panel>
Properties
Name | Type | Default | Description |
---|---|---|---|
header | string | null | Header text of the panel. |
toggleable | boolean | false | Defines if content of panel can be expanded and collapsed. |
collapsed | boolean | false | Defines the initial state of panel content, supports one or two-way binding as well. |
style | string | null | Inline style of the component. |
styleClass | string | null | Style class of the component. |
expandIcon | string | pi pi-plus | Expand icon of the toggle button. |
collapseIcon | string | pi pi-minus | Collapsed icon of the toggle button. |
showHeader | boolean | true | Specifies if header of panel cannot be displayed. |
transitionOptions | string | 400ms cubic-bezier(0.86, 0, 0.07, 1) | Transition options of the animation. |
toggler | string | icon | Specifies the toggler element to toggle the panel content, valid values are "icon" and "header". |
Events
Name | Parameters | Description |
---|---|---|
onBeforeToggle | event.originalEvent: browser event event.collapsed: state as a boolean | Callback to invoke before content toggle. |
onAfterToggle | event.originalEvent: browser event event.collapsed: state as a boolean | Callback to invoke after content toggle. |
Styling
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-panel | Container element. |
ui-panel-titlebar | Header section. |
ui-panel-title | Title text of panel. |
ui-panel-titlebar-toggler | Toggle icon. |
ui-panel-content | Content of panel. |
Dependencies
None.
Source
<p-toast [style]="{marginTop: '80px'}"></p-toast>
<p-panel header="Godfather I" [toggleable]="true" [style]="{'margin-bottom':'20px'}">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-panel>
<p-panel>
<p-header>
<div class="ui-helper-clearfix">
<span class="ui-panel-title" style="font-size:16px;display:inline-block;margin-top:2px">Custom Header</span>
<p-splitButton [style]="{'float':'right'}" label="Save" icon="pi pi-check" (onClick)="save()" [model]="items"></p-splitButton>
</div>
</p-header>
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
<p-footer>
<button pButton type="button" icon="pi pi-plus" label="New" class="ui-button-info" style="margin-right: .25em"></button>
<button pButton type="button" icon="pi pi-search" label="View" class="ui-button-success"></button>
</p-footer>
</p-panel>