I'm trying to find a way to have 3rd level menus in the side bar for my AdminLTE (V3.1.0) portal. Basically i'm trying to achieve something like below:
<ul id="sidebarTree" class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="true">
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-address-book"></i>
<p>
LEVEL 1 ITEM
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="#" class="nav-link" id="level2item">
<i class="nav-icon far fa-circle"></i>
<p>LEVEL 2 ITEM/p>
</a>
</li>
<a href="#" class="nav-link">
<i class="nav-icon fas fa-address-book"></i>
<p>
LEVEL 2 ITEM - EXPANDABLE
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="#" class="nav-link" id="level3item">
<i class="nav-icon far fa-circle"></i>
<p>LEVEL 3 ITEM/p>
</a>
</li>
</ul>
</ul>
</li>
Does anyone have any idea how this can be done? Or can this even be done at all?
See here (https://adminlte.io/docs/3.1//components/main-sidebar.html) for how the sidebar looks like in their docs.
CodePudding user response:
Yes it is possible, all you have to do is add the class name nav-item
to the parent li
.
li > ul {
margin-left: 25px;
}
<link rel="stylesheet" href="https://adminlte.io/docs/3.1//assets/css/adminlte.min.css">
<ul id="sidebarTree" class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="true">
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-address-book"></i>
<p>
LEVEL 1 ITEM
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="#" class="nav-link" id="level2item">
<i class="nav-icon far fa-circle"></i>
<p>LEVEL 2 ITEM</p>
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-address-book"></i>
<p>
LEVEL 2 ITEM - EXPANDABLE
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="#" class="nav-link" id="level3item">
<i class="nav-icon far fa-circle"></i>
<p>LEVEL 3 ITEM</p>
</a>
</li>
</ul>
</li>
</ul>
</li>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="/docs/3.1//assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/docs/3.1//assets/js/adminlte.min.js"></script>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
Note: Stackoverflow restricts some imports here you can view it in my codepen below
Working example here: https://codepen.io/Ev1ltw1n/pen/rNzOoob