AttRibutes
Accordion
What is this page about?

Attributes, by Finsweet, offers a free series of Solutions that provide essential features to improve your Webflow websites.

Accordion

Create accessible accordions inside Webflow without Webflow Interactions.

Accordion • Flash Card

Copy Script

For advanced users familiar with this solution. Includes all attributes from this page. Click on attributes and values to copy them.

Required attributes

Accordion

This is the outer wrapper of one accordion item. This element must contain one trigger and one content element inside.

fs-accordion-element
=
"
accordion
"

Trigger

This element triggers the open and close of the accordion item content.

fs-accordion-element
=
"
trigger
"

Content

This element wraps the content of the accordion and will expand and close when the trigger is clicked.

fs-accordion-element
=
"
content
"

Arrow

This element is the arrow inside the accordion trigger.

fs-accordion-element
=
"
arrow
"

Optional attributes

Active class

When an accordion has expanded content, any element with the fs-accordion-active class will receive this class as an active state.

fs-accordion-active
=
"
is-active-accordion
"

Group

This element wraps all accordion items that should be classified as part of the same "group".

fs-accordion-element
=
"
group
"

Group | Single

This forces one single accordion open at any time.

fs-accordion-single
=
"
true
"

Group | Initial

This sets which accordion items in the group are open on load.

Can be only one or multiple accordions with a comma separated list as the value

fs-accordion-initial
=
"
NUMERIC_INDEX
"
1

Add this <script> inside the <head> tag of your page or project

This script is the universal Attribute script: you only need to include it once, even if you have multiple Attribute solutions on the page. Learn more .

<script async type="module"
src="https://cdn.jsdelivr.net/npm/@finsweet/attributes@2/attributes.js"
fs-accordion
></script>

Copy Script
2

Choose if you need a sinlge accordion or a group of accordions

2

Add these required attributes to the elements

div block icon

Accordion

Define the wrapper for the accordion
fs-accordion-element
=
"
accordion
"

This is the outer wrapper of one accordion item. This element must contain one trigger and one content element inside.

Add this attribute:
Name
fs-accordion-element
Copy
Value
accordion
Copy
Elements allowed:
Div Block
IMPORTANT

If there are 5 accordion items, this attribute should be placed on each item.

back arrow
div block icon

Trigger

Toggles the open and close state of the accordion
fs-accordion-element
=
"
trigger
"

This element triggers the open and close of the accordion item content.

There is no requirement for parent, child, or sibling relationships between the trigger and the content.

Add this attribute:
Name
fs-accordion-element
Copy
Value
trigger
Copy
Elements allowed:
Div Block
IMPORTANT

It is required to be inside an accordion element.

div block icon

Content

Defines the element that holds the expanded accordion content
fs-accordion-element
=
"
content
"

This element wraps the content of the accordion and will expand and close when the trigger is clicked.

There is no requirement for parent, child, or sibling relationships between the trigger and the content.

Add this attribute:
Name
fs-accordion-element
Copy
Value
content
Copy
Elements allowed:
Div Block
IMPORTANT

It is required to be inside an accordion element.

3

Add these required attributes to the elements

div block icon

Group

Define the wrapper for the accordion group
fs-accordion-element
=
"
group
"

This element and attribute is only required to use group options.

This attribute wraps all accordion items that should be classified as part of the same "group".

Add this attribute:
Name
fs-accordion-element
Copy
Value
group
Copy
Elements allowed:
Div Block
WHERE TO ADD IT
NOTE
IMPORTANT

If using a CMS Collection List, this attribute can be placed once on the Collection Item element.

div block icon

Accordion

Define the wrapper for the accordion
fs-accordion-element
=
"
accordion
"

This is the outer wrapper of one accordion item. This element must contain one trigger and one content element inside.

Add this attribute:
Name
fs-accordion-element
Copy
Value
accordion
Copy
Elements allowed:
Div Block
WHERE TO ADD IT
NOTE
IMPORTANT

If there are 5 accordion items, this attribute should be placed on each item. If using a CMS Collection List, this attribute can be placed once on the Collection Item element.

Nested in
div block icon

Trigger

Toggles the open and close state of the accordion
fs-accordion-element
=
"
trigger
"

This element triggers the open and close of the accordion item content.

There is no requirement for parent, child, or sibling relationships between the trigger and the content.

Add this attribute:
Name
fs-accordion-element
Copy
Value
trigger
Copy
Elements allowed:
Div Block
IMPORTANT

It is required to be inside an accordion element.

div block icon

Content

Defines the element that holds the expanded accordion content
fs-accordion-element
=
"
content
"

This element wraps the content of the accordion and will expand and close when the trigger is clicked.

There is no requirement for parent, child, or sibling relationships between the trigger and the content.

Add this attribute:
Name
fs-accordion-element
Copy
Value
content
Copy
Elements allowed:
Div Block
IMPORTANT

It is required to be inside an accordion element.

4

Publish your project! Done, easy right?

Check more elements and settings below
Optional

Add more

options

Arrow

This element will receive the active class when the content is expanded
fs-accordion-element
=
"
arrow
"

This element is the arrow inside the accordion trigger.

This arrow element will receive the active class when the content is expanded.

Use Webflow native transition and transform CSS properties to create custom animations for the arrow.

Add this attribute:
Name
fs-accordion-element
Copy
Value
arrow
Copy
Elements allowed:
div block icon
Div Block
EXAMPLE

For example, apply a rotate 180 degrees transform to the arrow element active state. This will create an arrow rotation effect.

Active

Add a custom class to the accordion element
fs-accordion-active
=
"
is-active-accordion
"

Optionally customize the active class applied to elements in the accordion.

The default class name is .is-active-accordion. This class is applied to the accordion, trigger, content, and arrow.

To keep the default class name, there is no need to add this attribute. To change the class name, set the value as the custom class name you want.

When an accordion has expanded content, any element with the fs-accordion-active class will receive this class as an active state.

Add this attribute:
Name
fs-accordion-active
Copy
Value
is-active-accordion
Copy
Elements allowed:
Add to any element with
fs-accordion-element = "accordion | trigger | content | group"
NOTE

Apply this attribute to the group element for the active class to cascade down to all elements in the accordion. All elements in the accordion will inherit the group settings.

Optional

Add more

group options

Single

Only one accordion will be opened at a time
fs-accordion-single
=
"
true
"

This option forces one single accordion open at any time. When a second accordion is opened in a group, the previous opened accordion closes.

By default, this option is set to false and all accordions can be opened without forced close.

Add this attribute:
Name
fs-accordion-single
Copy
Value
true
Copy
Add it to the element with
fs-accordion-element = "group"

Initial

Define which accordion elements will be open on page load
fs-accordion-initial
=
"
NUMERIC_INDEX
"

This option sets which accordion items in the group are open on load.

By default, this option is set to "1" to have all items closed on load set the value to "none".


NUMERIC_INDEX
- A comma-separated list of indexes that define which accordions should be open.

Add this attribute:
Name
fs-accordion-initial
Copy
Value
NUMERIC_INDEX
Copy
Add it to the element with
fs-accordion-element = "group"
EXAMPLE

For example,"1" - The first accordion in the group is open.

"5" - The 5th accordion in the group is open.

"1, 4, 9" - The 1st, 4th, and 9th accordions in the group are open.

Optional

Add more

Instances

Define an instance on a common parent wrapper

fs-accordion-instance
=
"
IDENTIFIER
"

If you wish to create multiple instances of this solution on the same page, please follow the steps below:

  1. Select a wrapper parent that contains all the elements of an instance.
  2. Add an -instance attribute to it, with a unique value.
  3. Repeat for every instance.
Add this attribute:
Name
fs-accordion-instance
Copy
Value
IDENTIFIER
Copy
Examples:
fs-accordion-instance = "1"
fs-accordion-instance = "2"
fs-accordion-instance = "faq"
fs-accordion-instance = "details"
Learn more ways to set up multiple instances and how it works