Create a custom accordion - Webflow help

How to add a dropdown element
The dropdown element has default built-in actions that make it useful as a custom accordion — it opens the dropdown list when clicked and closes it when a different element or part of the page is clicked.
You can add a dropdown element to your site by going to Add panel (A) > Elements > Advanced and dragging the dropdown element onto the canvas.
How to change the default dropdown styles
To use the dropdown in your custom accordion, you’ll need to change the default dropdown element styles. In particular, you’ll need to adjust the width so that the dropdown completely fills the space of its parent element (i.e., whatever element holds the custom accordion).
To change the default dropdown styles:
- Select the parent dropdown element on the Designer canvas (given a class of “Accordion item” for this example)
- Go to Style panel > Size
- Set Width to 100%
How to customize your dropdown toggle
Now, you’ll need to customize your dropdown toggle so it completely fills its parent element and hides the content inside of the dropdown list when the accordion is closed. Adjust the dropdown toggle’s display and height properties:
- Select the dropdown toggle on the canvas and give it a class (e.g., “Accordion toggle”)
- Go to Style panel > Layout
- Set Display to flexbox to fill the horizontal space
- Set Align to center to vertically center the text
- Go to Style panel > Size
- Set a Height value (e.g., 80px)
How to style your accordion
If you preview your site and click your accordion, you may notice the accordion opens, but the default content overlays content around it. This occurs because the default position style for the dropdown list is absolute. You'll want to change it so content expands and shifts surrounding elements.
To style your accordion:
- Select the parent dropdown element (e.g., “Accordion item”)
- Click the “cog” icon to open Dropdown settings and show the Menu
- Select the Dropdown list element
- Go to Style panel > Position
- Set Position to static
- Select the parent dropdown element (“Accordion item”)
- Go to Style panel > Size
- Set Overflow to hidden
How to create your custom animation
Create a custom animation that opens and closes your custom accordion:
Create initial actions
You’ll start by creating two initial actions for your accordion.
For your dropdown:
- Select the dropdown element (“Accordion item”)
- Go to Interactions panel > Element trigger and create a new element trigger
- Choose Dropdown opens
- Select an action under Menu opens
- Choose Start an animation under Custom animation
- Create a timed animation and name it (e.g., “Accordion opens”)
- Add an action to your animation: Size under Miscellaneous
- Set as initial state
- Enter a height value (e.g., 80px)
- Save
For your toggle icon:
- Select the Icon within the dropdown element
- Give your icon class (e.g., “Accordion icon”)
- Select parent dropdown element
- Open Interactions panel
- Select Dropdown opens interaction
- Edit the timed animation (“Accordion opens”)
- Select the icon (“Accordion icon”)
- Add action: Rotate under Transform
- Set as initial state
- Set z-axis to 0 degrees
- Save
Animate the accordion opening
To open accordion and rotate icon:
- Select parent dropdown element
- Open Interactions panel
- Choose Dropdown opens interaction
- Edit timed animation (“Accordion opens”)
- Add action: Size under Miscellaneous
- Uncheck initial state
- Enter “auto” for height
- Select icon (“Accordion icon”)
- Add action (at same timestamp): Rotate under Transform
- Set z-axis to 180 degrees
- Save
Animate the accordion closing
To animate closing:
- Select parent dropdown element (“Accordion item”)
- Open Interactions panel
- Choose Dropdown opens interaction
- Select action under Menu closes
- Choose Start animation
- Create timed animation and name it (e.g., “Accordion closes”)
- Add action: Size under Miscellaneous
- Enter height value (e.g., 80px)
- Select icon
- Add action (same timestamp): Rotate under Transform
- Set z-axis to 0 degrees
- Save