Vertically collapsing panels for managing dense content.

Demo

Installation

Install the component

  1. Install the component

    Shell
    php artisan flexi:add accordion
  2. Install dependencies

    This component requires JS. By default we're using our own Interactive Component Library Flexilla .
    Shell
    npm i @flexilla/accordion
  3. Usage

    1. With Alpine/Livewire
    2. Add plugin in app.js

      flexilla.js
      import { AccordionPlugin } from "./plugins/accordion";
      
      Alpine.plugin(AccordionPlugin);
    3. Without Alpine
    4. Initialize accordion in app.js

      flexilla.js
      import { Accordion } from "@flexilla/accordion"
      
      // init accordion for all Element with data-app-accordion attribute
      Accordion.autoInit('[data-app-accordion]') 

Open multiple

Variants

Solid

Soft

Outline

Subtle

References

Composition

Prop Description
x-ui.accordion The accordion container component
x-ui.accordion.item The accordion item component
x-ui.accordion.trigger
The accordion trigger component of each item, each item must have one trigger
x-ui.accordion.content
The accordion content component of each item, each item must have one content and it will be hidden by default and shown when the trigger is clicked
x-ui.accordion.indicator
The accordion item indicator component, the default is a arrow icon that will be rotated when the item is open. Must be inside the trigger.

Props

To configure the accordion component you can use the following props. All props are optional.

Prop Description
defaultValue
The default value of the accordion, it will be the value of the item that will be open by default.
type
The type of the accordion, it can be "single" or "multiple".
keepOneOpen (boolean)
If true, the accordion will keep one item open at a time. All items can't be closed at the same time.
multiple (boolean)
The equivalent of type="multiple"

Item Props

Prop Description
id (string)
The id of the accordion item. It's required and must be unique.