Vue Accordion Component

Last updated: 13.03.2026
Views: 748

A simple and lightweight Vue 3 accordion component plugin. Supports both global plugin registration and local component usage. Written in TypeScript. The accordion component contains a minimum of CSS styles, which makes it easy to integrate into any of your designs. You can install the component using the NPM or Yarn package managers. The component allows you to configure the ability to have one or several elements of the accordion active at the same time. The CSS class “active” is added to the open accordion element.

Demo: https://vue.webstep.top/ws-acc

Installation

# via npm
npm install vue-ws-acc

# or via yarn
yarn add vue-ws-acc

Usage

1. Global registration (as a plugin)

import { createApp } from 'vue';
import App from './App.vue';
import VueWsAcc from 'vue-ws-acc';
import 'vue-ws-acc/dist/vue-ws-acc.css';

const app = createApp(App);
app.use(VueWsAcc);
app.mount('#app');

Now the component <VueWsAcc /> is available globally.

2. Local registration (per component)

<template>
  <VueWsAcc :items="accordionItems" />
</template>

<script lang="ts" setup>
import VueWsAcc from 'vue-ws-acc';
import 'vue-ws-acc/dist/vue-ws-acc.css';

const accordionItems = [
  { title: 'Section 1', content: 'Content for section 1' },
  { title: 'Section 2', content: 'Content for <strong>section</strong> 2' }
];
</script>

The “content” value may contain HTML tags.

Multiple

By default, only one accordion element can be active at a time. However, this behavior can be changed using the “multi” attribute, allowing multiple elements to be active at once.

<VueWsAcc :items="accordionItems" multi />

Styles

The component uses a minimum of CSS styles. These styles are easy to override. However, if you need to disable optional component styles, you can do so using the “simple” attribute.

<VueWsAcc :items="accordionItems" simple />

Props

Prop Type Default Description
items Array [] Array of accordion items
simple Boolean false Disable optional styles
multi Boolean false Allow multiple sections open

Example item: { title: string, content: string }

NPM: https://www.npmjs.com/package/vue-ws-acc
GitHub: https://github.com/igorrybalko/vue-ws-acc

author
Author: Igor Rybalko
I have been working as a front-end developer since 2014. My main technology stack is Vue.js and WordPress.

Similar posts:

  • jQuery Accordion Plugin
    An accordion is often used on websites. This element is popular and convenient at the same time. An accordion helps to structure content and save space. In my work, I oft...
  • Converting an Image to Base64 Using JavaScript
    Converting an image to a Base64 string in JavaScript can be extremely useful in many modern web development scenarios. One of the most common reasons for using Base64 is ...
  • How to Submit a Form Using jQuery Ajax ($.ajax)
    Submitting a form using jQuery's $.ajax method is a powerful way to send data to the server without reloading the page. This approach improves user experience and allows ...

3 responses to “Vue Accordion Component”

  1. vorbelutrioperbir says:

    Hi my friend! I wish to say that this post is amazing, nice written and include almost all vital infos. I would like to see extra posts like this .

  2. zimerov ertover says:

    Hello there! This is my first visit to your blog! We are a collection of volunteers and starting a new project in a community in the same niche. Your blog provided us valuable information to work on. You have done a wonderful job!

  3. zimerovertover says:

    I have been exploring for a little for any high-quality articles or weblog posts in this sort of space . Exploring in Yahoo I eventually stumbled upon this web site. Reading this info So i’m glad to express that I have an incredibly just right uncanny feeling I found out exactly what I needed. I such a lot unquestionably will make sure to do not overlook this web site and provides it a look on a continuing basis.

Leave a Reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*