Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aria-expanded="false" Not working in bootstrap template

Tags:

bootstrap-4

I have downloaded this template

https://startbootstrap.com/themes/sb-admin-2/

And there is page in there called cards.html

On that page is a collapsible card example. I'm trying to get it so that it loads collapsed and the user has to expand it. So I changed this section to be:

<div class="card shadow mb-4">
<!-- Card Header - Accordion -->
<a href="#collapseCardExample" class="d-block card-header py-3" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="collapseCardExample">
  <h6 class="m-0 font-weight-bold text-primary">Collapsable Card Example</h6>
</a>
<!-- Card Content - Collapse -->
<div class="collapse show" id="collapseCardExample">
  <div class="card-body">
    This is a collapsable card example using Bootstrap's built in collapse functionality. <strong>Click on the card header</strong> to see the card body collapse and expand!
  </div>
</div>
</div>

It did have:

aria-expanded="true"

but I made it false.

Why is it still loading as expanded?

like image 327
Rodney Ellis Avatar asked Mar 19 '26 14:03

Rodney Ellis


1 Answers

Bootstrap doesn't rely on aria things, it uses its own data attributes. (aria is for screen readers.

To hide it, remove the show class from collapseCardExample. See https://getbootstrap.com/docs/4.3/components/collapse/

like image 116
Steffan Avatar answered Mar 26 '26 14:03

Steffan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!