Home > Enterprise >  What is the meaning of class collapsed in bootstrap 4?
What is the meaning of class collapsed in bootstrap 4?

Time:10-05

I have noticed that while using accordions, the class "collapsed" is being used, not to be confused with the data-toggle="collapse". When I test what happens if I remove the collapsed class, well, the accordion works just as well even without the collapsed class issued to the buttons. For example you can look at the accordion example in the following link: https://getbootstrap.com/docs/4.0/components/collapse/

<button class="btn btn-link collapsed"...

Can someone explain what is the class "collapsed" and what it does please?

I have noted the following question in SO, but there is no explanation on the collapsed class functionality.

Bootstrap collapse menu arrows at initial state

CodePudding user response:

By reviewing Bootstrap v4.0 cdn, the collapsed class is only in the JavaScript file bootstrap.min.js and not present on any other file. Meaning it has no CSS style. It is used inside of loops and conditional statement and it does not matter if the user adds it or not, Bootstrap JavaScript will toggle that class supposedly to give the accordion the correct functionality, but I really don't see anything major related to that class, it may be something not having a real utility.

  • Related