Vitral 0.2
Panel

Panel

A titled container that can collapse behind its header.

Import

main.ts
import { Panel } from '@vitral/vue';

Basic

Header

A panel groups content under a header. Without `toggleable` the header is plain text.

<script setup lang="ts">import { Panel } from '@vitral/vue';</script> <template>    <Panel header="Header" style="width: 100%">        <p style="margin: 0">A panel groups content under a header. Without `toggleable` the header is plain text.</p>    </Panel></template>

Toggleable (Expander)

Press the header, or Tab to it and press Enter or Space, to collapse this content.

collapsed: false
<script setup lang="ts">import { Panel } from '@vitral/vue';import { ref } from 'vue'; const collapsed = ref(false);</script> <template>    <Panel v-model:collapsed="collapsed" header="Advanced settings" toggleable style="width: 100%">        <p style="margin: 0">Press the header, or Tab to it and press Enter or Space, to collapse this content.</p>    </Panel>    <small style="color: var(--vt-text-muted-color)">collapsed: {{ collapsed }}</small></template>

Custom toggle icon, starting collapsed

<script setup lang="ts">import { Panel } from '@vitral/vue';</script> <template>    <Panel header="Details" toggleable :collapsed="true" toggle-icon="plus" style="width: 100%">        <p style="margin: 0">A custom icon replaces the chevron and does not turn over.</p>    </Panel></template>

API

Read from packages/vue/src/components/Panel/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
headerstringThe header's text.
toggleablebooleanMakes the header a button that shows and hides the content.
toggleIconIconPropReplaces the chevron. The chevron turns over when open; a custom icon stays as it is.

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Emits

EventPayloadDescription
toggleevent: PanelToggleEvent—

Slots

NameSlot propsDescription
header—Replaces the `header` text. Inside the toggle button when toggleable, so it must not hold controls of its own.
icons—Actions at the end of the header; kept outside the toggle button.
toggleicon(props: { collapsed: boolean })—
default——
footer——