Vue3 Panel

Vue3 Panel

·

4 min read

Vue3 Panel is a container with the optional content toggle feature. It supports Vue 3 with PrimeVue 3 and Vue 2 with PrimeVue 2.

Setup

Refer to PrimeVue setup documentation for download and installation steps for your environment such as Vue CLI, Vite or browser.

Import

import Panel from 'primevue/panel';

Getting Started

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>

Custom Header

Header of the panel is either defined with the header property or the header template.

<Panel>
    <template #header>
        Header Content
    </template>
    Content
</Panel>

Toggleable

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>

Custom Icons

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>

Theming

Panel supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.

Resources

Visit the PrimeVue Panel showcase for demos and documentation.