Skip to content

Accordion ​

The bo-accordion component renders vertically stacked collapsible sections. It supports one or multiple open items, controlled or uncontrolled state, collapsible sections, and disabled items.

Basic Usage ​

Use bo-accordion with one or more bo-accordion-item components. Set default-value to open an item initially without using v-model:

A manifest-driven Vue component library.

<bo-accordion default-value="one">
  <bo-accordion-item value="one">
    <template #trigger>What is Bamboo?</template>
    <template #content>A manifest-driven Vue component library.</template>
  </bo-accordion-item>
  <bo-accordion-item value="two">
    <template #trigger>Is it themeable?</template>
    <template #content>Yes. Bamboo uses CSS tokens for theming.</template>
  </bo-accordion-item>
  <bo-accordion-item value="three">
    <template #trigger>Can I nest content?</template>
    <template #content>Any content can be placed inside the content slot.</template>
  </bo-accordion-item>
</bo-accordion>

Multiple Opened Items ​

Set multiple to allow more than one item to remain open. With multiple, the model value is an array:

Manage email and push notifications.

Review account privacy and security settings.

Open values: one, two

<bo-accordion v-model="openItems" multiple>
  <bo-accordion-item value="one">
    <template #trigger>Notification settings</template>
    <template #content>Manage email and push notifications.</template>
  </bo-accordion-item>
  <bo-accordion-item value="two">
    <template #trigger>Privacy and security</template>
    <template #content>Review account privacy and security settings.</template>
  </bo-accordion-item>
  <bo-accordion-item value="three">
    <template #trigger>Billing</template>
    <template #content>Manage billing details and invoices.</template>
  </bo-accordion-item>
</bo-accordion>

Set collapsible to false to prevent the last open item from closing. It defaults to true.

Disabled Items ​

Set disabled on the accordion to disable every item, or set it on an individual item:

This section remains interactive.

<bo-accordion default-value="one">
  <bo-accordion-item value="one">
    <template #trigger>Available section</template>
    <template #content>This section remains interactive.</template>
  </bo-accordion-item>
  <bo-accordion-item value="two" disabled>
    <template #trigger>Disabled section</template>
    <template #content>This section cannot be opened.</template>
  </bo-accordion-item>
</bo-accordion>

Items and Slots ​

The value prop identifies an item and accepts a string or number. Use the trigger slot for the clickable heading and the content slot for the collapsible body. The default slot is used as trigger content when trigger is not provided:

Content supplied through the content slot.

<bo-accordion default-value="one">
  <bo-accordion-item value="one">
    Default slot as trigger
    <template #content>Content supplied through the content slot.</template>
  </bo-accordion-item>
  <bo-accordion-item value="two">
    <template #trigger>
      <span class="font-semibold">Plans</span>
      <span class="ms-auto rounded bg-neutral-600 px-1.5 py-0.5 text-xs">
        Pro
      </span>
    </template>
    <template #content>Any markup can be placed in the content slot.</template>
  </bo-accordion-item>
</bo-accordion>
vue
<bo-accordion-item :value="1">
  <span>Account details</span>
  <template #content>
    <p>Content can contain arbitrary markup and components.</p>
  </template>
</bo-accordion-item>

API Reference ​

Props (bo-accordion) ​

PropTypeDefaultDescription
idstringAutogeneratedThe id of the element.
dataTestIdstringAutogeneratedThe data test id of the element.
modelValuestring | number | (string | number)[]-The active item value or values.
defaultValuestring | number | (string | number)[]-The initially open item value or values.
multiplebooleanfalseWhether multiple items can be open at once.
collapsiblebooleantrueWhether the last open item can be closed.
disabledbooleanfalseWhether the accordion is disabled.

Props (bo-accordion-item) ​

PropTypeDefaultDescription
idstringAutogeneratedThe id of the element.
dataTestIdstringAutogeneratedThe data test id of the element.
valuestring | number-The value of the item.
disabledbooleanfalseWhether the item is disabled.
roleHTMLAttributes['role']-The role of the content region.

Events ​

EventPayloadDescription
update:modelValuestring | number | (string | number)[]Emitted when an item is toggled.

Slots ​

NameDescription
defaultbo-accordion: the accordion items.
defaultbo-accordion-item: trigger content when no trigger slot is given.
triggerbo-accordion-item: custom trigger content.
contentbo-accordion-item: the collapsible body.

Released under the MIT License.