Using the Collapse component

I find that the Collapse component's name is a bit confusing. What it really means is a collapsable section that can be shown or hidden on a click action. Let's start by creating a simple collapsable section of text on the index.ejs template. Open that template and insert the following code wherever you like:

<p><a class="btn btn-primary" data-toggle="collapse" href="#collapse-link" aria-expanded="false">Collapse Link Trigger</a></p> 

The Collapse component is broken into two parts. The first is the trigger to show or hide the collapsable content. The second is the actual content you want to show or hide. Let's review it in more detail to show how to code this up:

  • The first part is the trigger for the collapsable content, ...

Get Learning Bootstrap 4 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.