I have been following the bootstrap documentation for tabs which can be found at this link
After referencing the documentation, I replicated the sample implementation in my code as shown below:
---
title: Portfolio
description: Portfolio
---
{% extends "./layouts/layout.njk" %}
{% block scripts %}{% endblock %}
{% block styles %}{% endblock %}
{% block body %}
<div class="demo py-5">
<h2 class="my-5">Choose One of Our Demos</h2>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">Contact</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="disabled-tab" data-bs-toggle="tab" data-bs-target="#disabled-tab-pane" type="button" role="tab" aria-controls="disabled-tab-pane" aria-selected="false" disabled>Disabled</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0">A</div>
<div class="tab-pane fade" id="profile-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">B</div>
<div class="tab-pane fade" id="contact-tab-pane" role="tabpanel" aria-labelledby="contact-tab" tabindex="0">C</div>
<div class="tab-pane fade" id="disabled-tab-pane" role="tabpanel" aria-labelledby="disabled-tab" tabindex="0">D</div>
</div>
</div>
{% endblock %}
Although it appears correctly on the page, clicking the tabs does not function as expected. The content does not switch and always displays text "A", as that is the initial active tab set.
https://i.sstatic.net/2FXYa.png
I am uncertain about what might be missing here. Bootstrap 5 has been installed without issues. Could the problem be related to Nunjucks? Should a script be added somewhere, or where should JavaScript codes be placed when using Nunjucks? Any assistance would be greatly appreciated.