Bootstrap 4 Treeview
Bootstrap 4 Treeview plugin
Bootstrap treeview is used to show hierarchical information which starts from the root item and proceed to its children and their respective children. Each item besides the root has a parent and can have children.
Basic Bootstrap 4 version
<div class="treeview w-20 border">
<h6 class="pt-3 pl-3">Folders</h6>
<hr>
<ul class="mb-1 pl-3 pb-2">
<li><i class="fas fa-angle-right rotate"></i>
<span><i class="far fa-envelope-open ic-w mx-1"></i>Mail</span>
<ul class="nested">
<li><i class="far fa-bell ic-w mr-1"></i>Offers</li>
<li><i class="far fa-address-book ic-w mr-1"></i>Contacts</li>
<li><i class="fas fa-angle-right rotate"></i>
<span><i class="far fa-calendar-alt ic-w mx-1"></i>Calendar</span>
<ul class="nested">
<li><i class="far fa-clock ic-w mr-1"></i>Deadlines</li>
<li><i class="fas fa-users ic-w mr-1"></i>Meetings</li>
<li><i class="fas fa-basketball-ball ic-w mr-1"></i>Workouts</li>
<li><i class="fas fa-mug-hot ic-w mr-1"></i>Events</li>
</ul>
</li>
</ul>
</li>
<li><i class="fas fa-angle-right rotate"></i>
<span><i class="far fa-folder-open ic-w mx-1"></i>Inbox</span>
<ul class="nested">
<li><i class="far fa-folder-open ic-w mr-1"></i>Admin</li>
<li><i class="far fa-folder-open ic-w mr-1"></i>Corporate</li>
<li><i class="far fa-folder-open ic-w mr-1"></i>Finance</li>
<li><i class="far fa-folder-open ic-w mr-1"></i>Other</li>
</ul>
</li>
<li><i class="fas fa-angle-right rotate"></i>
<span><i class="far fa-gem ic-w mx-1"></i>Favourites</span>
<ul class="nested">
<li><i class="fas fa-pepper-hot ic-w mr-1"></i>Restaurants</li>
<li><i class="far fa-eye ic-w mr-1"></i>Places</li>
<li><i class="fas fa-gamepad ic-w mr-1"></i>Games</li>
<li><i class="fas fa-cocktail ic-w mr-1"></i>Coctails</li>
<li><i class="fas fa-pizza-slice ic-w mr-1"></i>Food</li>
</ul>
</li>
<li><i class="far fa-comment ic-w mr-1"></i>Notes</li>
<li><i class="fas fa-cogs ic-w mr-1"></i>Settings</li>
<li><i class="fas fa-desktop ic-w mr-1"></i>Devices</li>
<li><i class="fas fa-trash-alt ic-w mr-1"></i>Deleted Items</li>
</ul>
</div>
// Treeview Initialization
$(document).ready(function() {
$('.treeview').mdbTreeview();
});
Above is an example template for a Treeview in the Bootstrap 4 version based on jQuery. V4 is an older version of Bootstrap and we discourage implementing it in new projects.
Below you will find the same component but in the latest, more modern Bootstrap 5. We encourage you to use the v5 version instead, the v5 is more lightweight, more reliable and based on pure JavaScript instead of jQuery.
This page only compares the two version, you can find full documentation - with multiple options & API details via one of the links below:
Bootstrap v5 - full documentation
Bootstrap v4 - full documentation
Basic Bootstrap 5 version
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
<div data-mdb-treeview-init class="treeview">
<ul>
<li>One</li>
<li>Two</li>
<li>
<a>Three</a>
<ul class="show">
<li>Second-one</li>
<li>Second-two</li>
<li>
<a>Second-three</a>
<ul>
<li>
<a>Third-one</a>
<ul>
<li>Fourth-one</li>
<li>Fourth-two</li>
<li>Fourth-three</li>
</ul>
</li>
<li>Third-two</li>
<li>
<a>Third-three</a>
<ul>
<li>Fourth-one</li>
<li>Fourth-two</li>
<li>Fourth-three</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>