import Panel from 'primevue/panel';
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 p-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. |
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. |
None.
<h5>Regular</h5>
<Panel header="Header">
<p>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>
<h5>Advanced</h5>
<Panel header="Header" :toggleable="true">
<template #icons>
<button class="p-panel-header-icon p-link p-mr-2" @click="toggle">
<span class="pi pi-cog"></span>
</button>
<Menu id="config_menu" ref="menu" :model="items" :popup="true" />
</template>
<p>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>
export default {
data() {
return {
items: [
{
label: 'Options',
items: [{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
}
}
]},
{
label: 'Navigate',
items: [{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
to: '/fileupload'
}
]}
]
}
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
},
save() {
this.$toast.add({severity: 'success', summary: 'Success', detail: 'Data Saved', life: 3000});
}
}
}