# Accordion List Ionic?

**URL:** <https://forum.ionicframework.com/t/accordion-list-ionic/116612>\
**Category:** ionic-v3\
**Created:** [December 28, 2017, 12:57am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612 "2017-12-28T00:57:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielpt](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielpt/32/95937_2.png) [@danielpt](https://forum.ionicframework.com/u/danielpt)\
**Post date:** [December 28, 2017, 12:57am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/1 "2017-12-28T00:57:30Z")

</div>

Someone know how can i use accordion list on ionic 3?

I don’t find any solution =(  
… only ionic 1 and 2

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [December 28, 2017, 12:59am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/2 "2017-12-28T00:59:07Z")

</div>

Accordion list can be easily made using CSS3 & HTML5:

> **[CSS3 Accordion (No Javascript) - Vertical - Single Visible](https://codepen.io/mraffaele/pen/YGJXvm)**
>
> Pure HTML/CSS3 accordion menus using absolutely no javascript. This version uses vertical accordion type allowing one panel to be visible at a time. ...

> **[CSS3 Accordion](https://codepen.io/nickdominguez/pen/uBzEe)**
>
> This is a an accordion built with HTML, Sass & Compass. CSS3 is used for transition effects. Code was originally pulled from

> **[CSS3 Accordion Test (No 'height: auto' transition)](https://codepen.io/diegopardo/pen/pvkjx)**
>
> ...

> **[CSS3 Accordion Menu](https://codepen.io/charleslcsantos/pen/xGBLk?q=css3+accordion&limit=all&type=type-pens)**
>
> Create Accordion Menu Using CSS3 Transition: http://www.deluxeblogtips.com/2010/04/accordion-menu-css3-transition.html...

These examples will work on all versions of Ionic.

---

<div class="post-metadata">

**Author:** ![danielpt](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielpt/32/95937_2.png) [@danielpt](https://forum.ionicframework.com/u/danielpt)\
**Post date:** [December 28, 2017, 1:14am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/3 "2017-12-28T01:14:01Z")

</div>

Im searching for one ionic version… This does not seem to be the best way to do that.

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [December 28, 2017, 1:17am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/4 "2017-12-28T01:17:11Z")

</div>

web developers make accordion lists using JavaScript, JQuery and CSS3… however JQuery doesn’t work well on Ionic 3. Twitter Bootstrap accordion list is based on JQuery animation as well.  
In my opinion, CSS3 accordion is the best way although it will take some time to learn how it works.

Or you can try to combine it with original Ionic components.

> **[Ionic Framework](https://ionicframework.com/docs/components/)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

another solution is using Angular’s ngClass to dynamically add & remove CSS3 class on accordion list item. so once you click on accordion list item, angular will add a css3 class of display: inline or height: 350px to make the item expand its content.

---

<div class="post-metadata">

**Author:** ![danielpt](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielpt/32/95937_2.png) [@danielpt](https://forum.ionicframework.com/u/danielpt)\
**Post date:** [January 8, 2018, 8:07pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/5 "2018-01-08T20:07:43Z")

</div>

the problem of pure css accordion is the height… i need set a fixed height to animation, and its a problem for a big lists…

---

<div class="post-metadata">

**Author:** ![anna\_liebt](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@anna\_liebt](https://forum.ionicframework.com/u/anna_liebt)\
**Post date:** [January 8, 2018, 8:54pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/6 "2018-01-08T20:54:51Z")

</div>

Hello,

maybe it helps, when you attach css property height with ngstyle and calculate variable for ngstyle whenever you want

Best regards, anna-liebt

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [January 8, 2018, 9:19pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/7 "2018-01-08T21:19:20Z")

</div>

check these tutorials:

> **[Creating an Accordion List in Ionic](https://www.joshmorony.com/creating-an-accordion-list-in-ionic/)**
>
> Earlier this week I recorded a video where I walked through building an expandable component on screen. This was a generic component that could be given a specific height, and its state could be to…

> **[Accordion List with Ionic - Ionic Academy](https://ionicacademy.com/accordion-list-ionic/)**
>
> An Accordion list is a very classic UI pattern, for which you can find about 100 jQuery solutions. But we want to develop an accordion...

or try to copy from this demo project made by other guy:

> **[didinj/Ionic2AccordionList](https://github.com/didinj/Ionic2AccordionList)**
>
> Ionic2AccordionList - Ionic 2 Accordion List

CSS3 accordion works fine with Angular 5’s [ngClass] & (click) with boolean … but if you have problems, you can follow the step by step tutorials on Josh Morony’s website.

---

<div class="post-metadata">

**Author:** ![danielpt](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielpt/32/95937_2.png) [@danielpt](https://forum.ionicframework.com/u/danielpt)\
**Post date:** [January 16, 2018, 7:40pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/8 "2018-01-16T19:40:45Z")

</div>

All of them use itens with fixed height… its a great problem for me =(  
i already try…  
thanks

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [January 16, 2018, 7:42pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/9 "2018-01-16T19:42:10Z")

</div>

Then CSS3 accordion is your solution… you can set its height in anyway you want in CSS3.

Create CSS3 accordion list items with height of 0… and then you can use angular’s [ngClass] to dynamically change list item’s height into any way you want.

CSS3 animation transition can make this look more professional.

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [January 17, 2018, 5:08am UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/10 "2018-01-17T05:08:57Z")

</div>

Wait, for dynamic height of items, you can use max-height CSS property.

For instance, if max-height of item is set to 500px, items will be set to whatever under 500px.

Try max-height instead of height to set accordion list items’ height dynamically according to data.

---

<div class="post-metadata">

**Author:** ![danielpt](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danielpt/32/95937_2.png) [@danielpt](https://forum.ionicframework.com/u/danielpt)\
**Post date:** [January 17, 2018, 1:29pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/11 "2018-01-17T13:29:21Z")

</div>

Work… but become a new problem with transitions… the transitions don’t work well… try to put a big content inside the accordion that you find =(

i think need use JS…

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [January 17, 2018, 2:31pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/12 "2018-01-17T14:31:26Z")

</div>

No, you can use [ngClass] to add transition to animation.

If you don’t know how to do that, please search ngClass of angular… it can dynamically add & remove CSS3.

So, accordion list item gets **transition: 0.5s ease all; max-height: 0;'**  
and [ngClass] will add **‘max-height: 500px;’** on (click)

EDIT: actually ngClass should add CSS3 animation and keyframes along with max-height property…  
animation-name: height-increase  
animation-duration: 0.5s;  
animation-iteration-count: 1;

@-webkit-keyframe height-increase {  
0% { height: 0px; }  
100% { max-height: 500px; }  
}

Something like that…hope this helps.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:57pm UTC](https://forum.ionicframework.com/t/accordion-list-ionic/116612/13 "2021-07-19T21:57:27Z")

</div>

Closed on July 19, 2021, 9:57pm UTC


