2.0.0 • Published 2 years ago

@dzangolab/vue-accordion v2.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

vue-accordion

An accordion component for vue.js.

Build Status codecov NPM NPM

Requirements

  • vue.js

License

This component is released under the MIT license. See LICENSE file for more details.

Installation

Global installation

import Accordion from '@dzangolab/vue-accordion'
import '@dzangolab/vue-accordion/dist/accordion.css' // import stylesheet

Vue.component(Accordion)

In-component installation

import Accordion from '@dzangolab/vue-accordion'
import '@dzangolab/vue-accordion/dist/accordion.css' // import stylesheet

export default {
  components: {
    Accordion
  }
}

Usage

The Accordion is meant to be usable out of the box. Include it in your template and pass it an items prop.

<Accordion
  :items="items"
/>

The items prop must be in the form of :

items: [
  {
    content: 'some content',
    title: 'Item 1'
  },
  {
    content: 'some more content',
    title: 'Item 2'
  },
  {
    content: 'some other content',
    title: 'Item 3'
  }
]

Slots

NameDescription
titleUse this slot to customize each item's title
toggleUse this slot to customize each item's toggle button
contentUse this slot to customize each item's content

Props

NameTypeDescriptionDefault
default-indexNumberThe item to be opened by default.0
durationNumberThe duration of the transition when an item is opened.350
itemsArrayThe list of items in the accordion.() => []
show-toggleBooleanWhether the toggle button should be shown in each accordion item.true
transitionStringThe transition to use when opening an accordion item."ease"

Data

NameTypeDescriptionInitial value
indexnumberThe index of the currently selected item.value of defaultIndex prop

Events

NameDescription
accordion:selectFired when an accordion item is selected.Argumentsindex: number — the zero-based index of the selected item.

Methods

isActive()

Whether the item at specified index is open.

Syntax

isActive(index: number): unknown

Parameters

  • index: number the index of the element to be checked
2.0.0

2 years ago

2.0.0-rc.2

3 years ago

1.2.0

3 years ago

2.0.0-rc.3

3 years ago

2.0.0-rc.4

3 years ago

2.0.0-rc.5

3 years ago

2.0.0-rc.1

3 years ago

2.0.0-rc.6

3 years ago

2.0.0-rc.7

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.1.0

4 years ago