I am currently utilizing Bootstrap5
and Vue 3
. In my project, I have several buttons
, each of which triggers a different collapse
.
My goal is to have only one collapse open at a time, meaning that when I open one collapse, all the others should close. However, at the moment, all collapses remain open simultaneously.
I have attempted to use both data-parent
and data-bs-parent
, but neither seem to be effective in achieving this desired behavior.
Does anyone know how I can accomplish this? Thank you!
<div class="row margin-top">
<div class="col">
<div class="d-grid gap-2">
<button type="button" class="btn color-success" style="height: 200px;" data-bs-toggle="collapse" data-bs-target="#collapse-b1" aria-expanded="false" aria-controls="collapse-b1" data-bs-parent="#myGroup">
Button 1
</button>
</div>
</div>
<div class="col">
<div class="d-grid gap-2">
<button type="button" class="btn color-primary" style="height: 200px;" data-bs-toggle="collapse" data-bs-target="#collapse-b2" aria-expanded="false" aria-controls="collapse-b2" data-bs-parent="#myGroup">
Button 2
</button>
</div>
</div>
</div>
<div>
<div class="collapse" id="collapse-b1">
<div class="mt-3">
Text 1
</div>
</div>
<div class="collapse" id="collapse-b2">
<div class="mt-3">
Text 2
</div>
</div>
</div>