A simple, easily configurable accordion or collapsible for Vue, styled with Bulma.
Full docs here
$ npm install --save vue-bulma-accordion
$ yarn add vue-bulma-accordion
# Bulma is a peer dependency, you have to install it manually
$ yarn add bulma
$ npm install --save bulma
Single File Component:
import { BulmaAccordion, BulmaAccordionItem } from 'vue-bulma-accordion'
export default {
name: 'cool-component',
data() {
return {}
},
components: {
BulmaAccordion,
BulmaAccordionItem
}
}
Put a <BulmaAccordion>
item on your page. There are a few options for the accordion, though they have sensible defaults if you dont want to change anything:
true
, allows any number of items to be expanded simultaneously, rather than only 1 at a time'caret'
'plus-minus'
'custom'
- with this selected, you can provide your own icon in a slot, inside each accordion item. Either provide one icon in the 'icon'
slot, or a separate icon for when that accordion item is open or closed, in the 'icon-open'
and 'icon-closed'
slots'450ms'
'ease'
'700ms'
'ease'
Fill the <BulmaAccordion>
with as many <BulmaAccordionItem>
components as you need. Each of the <BulmaAccordionItem>
components has 3 slots, if you're not using a custom icon:
title
- I've found <h4 class="title is-4 has-text-weight-normal" slot="title">The Title</h4>
to look quite nicecontent
footer
There are a further 3 slots for custom icons:
icon
- when you just want 1 icon, DON'T USE WITH icon-open
and icon-closed
icon-open
- the icon shown when the <BulmaAccordionItem>
is openicon-closed
- the icon shown when the <BulmaAccordionItem>
is closed<BulmaAccordion
dropdown
:icon="'caret'"
:caretAnimation="{
duration: '.6s',
timerFunc: 'ease-in-out'
}"
:slide="{
duration: '.9s',
timerFunc: 'ease'
}"
>
<!-- The wrapper component for all the items -->
<BulmaAccordionItem>
<h4 slot="title">Just a title</h4>
</BulmaAccordionItem>
<!-- add as many of these items as you need - fill them with content via the slots -->
<BulmaAccordionItem>
<h4 slot="title">A title with content</h4>
<p slot="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus eos
illo expedita asperiores rem iure aliquid dolore, pariatur
dignissimos, minima inventore? Minima voluptatum nulla, error omnis
laboriosam voluptatibus rem aperiam.
</p>
</BulmaAccordionItem>
<BulmaAccordionItem>
<h4 slot="title">All of it</h4>
<p slot="content">boo</p>
<button class="button is-primary" slot="footer">Click Me!</button>
</BulmaAccordionItem>
</BulmaAccordion>
The icons used here are from https://material.io/icons/
<BulmaAccordion :dropdown="false" :icon="'custom'">
<!-- The wrapper component for all the items -->
<BulmaAccordionItem>
<p class="title is-4 has-text-weight-normal" slot="title">Title</p>
<i slot="icon" class="material-icons">more_vert</i>
<div class="high" slot="content"><p>This is a div with content</p></div>
<button class="button is-primary" slot="footer">Click Me!</button>
</BulmaAccordionItem>
<!-- add as many of these items as you need - fill them with content via the slots -->
<BulmaAccordionItem>
<h4 slot="title">A title with content</h4>
<i slot="icon-closed" class="material-icons">flight_takeoff</i>
<i slot="icon-open" class="material-icons">flight_land</i>
<p slot="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus eos
illo expedita asperiores rem iure aliquid dolore, pariatur
dignissimos, minima inventore? Minima voluptatum nulla, error omnis
laboriosam voluptatibus rem aperiam.
</p>
</BulmaAccordionItem>
</BulmaAccordion>