Skip to content

Accordion

Use the accordion component to show hidden information based on the collapse and expand state of the child elements using data attribute options

Examples

Accordion

A basic accordion function.

Code
vue
<template>
  <base-accordion>
    <base-accordion-item :item-id="1" title="Accordion #1" content="Hello World" />
    <base-accordion-item :item-id="2" title="Accordion #2" content="Hello World" />
    <base-accordion-item :item-id="3" title="Accordion #3" content="Hello World" />
  </base-accordion>
</template>

Always Open

The Collapse component is used to create regions of content that can expand/collapse with a simple animation. It helps to hide content that's not immediately relevant to the user.

Code
vue
<template>
  <base-accordion :alwaysOpen="true">
    <base-accordion-item :item-id="1" title="Accordion #1" content="Hello World" />
    <base-accordion-item :item-id="2" title="Accordion #2" content="Hello World" />
    <base-accordion-item :item-id="3" title="Accordion #3" content="Hello World" />
  </base-accordion>
</template>

Using Slot

Using slot for rendering accordion item title & content

Code
vue
<template>
  <base-accordion>
    <base-accordion-item :item-id="1">
      <template #title>Accordion #1</template>
      <template #default>Hello World</template>
    </base-accordion-item>
    <base-accordion-item :item-id="2">
      <template #title>Accordion #2</template>
      <template #default>Hello World</template>
    </base-accordion-item>
    <base-accordion-item :item-id="3">
      <template #title>Accordion #3</template>
      <template #default>Hello World</template>
    </base-accordion-item>
  </base-accordion>
</template>

Accordion API

Props

NameTypeDefaultDescription
alwaysOpenbooleanfalseDisable behavior automatic close another accordion item

Slot

#default slot for rendering accordion item

Accordion Item API

Props

NameTypeDefaultDescription
item-idstringAccordion item identifier is required and should be unique. It used for calculate height each item and manage active state
titlestringAccordion item title.
contentstringAccordion item content.

Slot

#default slot for rendering accordion item content

#title slot for rendering accordion item title

Released under the MIT License.