Skip to content

Accordion

te-accordion collapses each panel with a CSS grid transition, so panels animate to their natural height with no JavaScript measuring.

Basic

Content of the first panel.

Content of the second panel.

Content of the third panel.
vue
<te-accordion :items="['First', 'Second', 'Third']">
  <template #content-1>Content of the first panel.</template>
  <template #content-2>Content of the second panel.</template>
  <template #content-3>Content of the third panel.</template>
</te-accordion>

Single open

Opening a panel closes the others.

Only one panel stays open.

Opening this one closes the other.
vue
<te-accordion single-open :items="['First', 'Second']">
  <template #content-1>Only one panel stays open.</template>
  <template #content-2>Opening this one closes the other.</template>
</te-accordion>

Flush and open by default

Open on mount.

Closed on mount.
vue
<te-accordion flush :items="['First', 'Second']" :default-open="[0]">
  <template #content-1>Open on mount.</template>
  <template #content-2>Closed on mount.</template>
</te-accordion>

Custom headers

Body.
vue
<te-accordion :items="['Ignored']">
  <template #header-1><strong>Custom</strong>&nbsp;header</template>
  <template #content-1>Body.</template>
</te-accordion>

Props

PropTypeDefaultDescription
itemsunknown[][]One entry per panel. The value is the default header label.
flushbooleanfalseRemoves the outer borders and rounding.
singleOpenbooleanfalseOnly one panel open at a time. Changing this closes everything.
defaultOpennumber[][]Indexes open on mount. Copied, never mutated.

Events

EventPayloadDescription
opennumberIndex of the panel that opened.
closenumberIndex of the panel that closed.

Slots

SlotPropsDescription
header-N{ title }Header of the Nth panel, starting at header-1.
content-NBody of the Nth panel, starting at content-1.

Released under the MIT License.