1.0.2 • Published 3 years ago

@2alheure/vue-accordion v1.0.2

Weekly downloads
-
License
WTFPL
Repository
github
Last release
3 years ago

Vue JS Accordion

A simple Accordion component for Vue JS.
This component is compatible with Vue 3.

Installation

First, run npm install @2alheure/vue-accordion.
Then import it with import Accordion from "@2alheure/vue-accordion";.

Usage

Simple usage example

<Accordion :headerStyle="headerStyle" :contentStyle="contentStyle">
  <template #header">
    Your accordion title. Can also be <strong>HTML</strong>.
  </template>

  Your accordion content. It can be simple text like this.
  <p>It can also be HTML.</p>
</Accordion>

<script>
  import Accordion from "@2alheure/vue-accordion";
  
  export default {
    components: {
      Accordion
    },
    data() {
      return {
        headerStyle: 'background-color: white;',
        contentStyle: {
          color: 'red',
          fontSize: '42px'
        }
      }
    }
  };
</script>

Props

NameTypeDefault valueDescription
openedBooleanfalseWhether the content should be displayed when loaded.
symbolOpenedString&or;The symbol to use for the opened accordion. (Can be HTML.)
symbolClosedString&gt;The symbol to use for the closed accordion. (Can be HTML.)
headerStyleString / Objectpadding: .5rem;The style for the header.
symbolStyleString / Objectfont-size: 1.5rem; font-weight: 700; vertical-align: middle;The style for the symbol.
contentStyleString / Objectwidth: 98%; margin: auto; padding: .5rem;The style for the content.
accordionClassString / ObjectnullThe classes for the accordion.
headerClassString / ObjectnullThe classes for the header.
symbolClassString / ObjectnullThe classes for the symbol.
contentClassString / ObjectnullThe classes for the content.

Events

NameDescription
openEmitted each time the accordion is opened.
closeEmitted each time the accordion is closed.
switchEmitted each time the accordion switches between open and close.