xxxxxxxxxx
1
<!-- Sidenav-->
2
<nav
3
id="sidenav-4"
4
class="sidenav"
5
data-mdb-mode="side"
6
data-mdb-slim="true"
7
data-mdb-slim-collapsed="true"
8
data-mdb-content="#slim-content"
9
data-mdb-transition-duration="0"
10
11
>
12
<ul class="sidenav-menu">
13
<li class="sidenav-item">
14
<a class="sidenav-link">
15
<i class="far fa-smile me-3"></i
16
><span data-mdb-slim="false">Link 1</span></a
17
>
18
</li>
19
<li class="sidenav-item">
20
<a class="sidenav-link"
21
><i class="fas fa-grin me-3"></i
22
><span data-mdb-slim="false">Category 1</span></a
23
>
24
<ul class="sidenav-collapse">
25
<li class="sidenav-item">
26
<a class="sidenav-link">Link 2</a>
27
</li>
28
<li class="sidenav-item">
29
<a class="sidenav-link">Link 3</a>
30
</li>
31
</ul>
32
</li>
33
<li class="sidenav-item">
34
<a class="sidenav-link"
35
><i class="fas fa-grin-wink me-3"></i
36
><span data-mdb-slim="false">Category 2</span></a
37
>
38
<ul class="sidenav-collapse">
39
<li class="sidenav-item">
40
<a class="sidenav-link">Link 4</a>
41
</li>
42
<li class="sidenav-item">
43
<a class="sidenav-link">Link 5</a>
44
</li>
45
</ul>
46
</li>
47
</ul>
48
</nav>
49
<!-- Sidenav-->
50
51
<!-- Togglers -->
52
<div id="slim-content">
53
<button
54
data-mdb-toggle="sidenav"
55
data-mdb-target="#sidenav-4"
56
class="btn btn-primary"
57
aria-controls="#sidenav-4"
58
aria-haspopup="true"
59
>
60
<i class="fas fa-bars"></i>
61
</button>
62
<button id="slim-toggler" class="btn btn-primary">
63
Toggle slim
64
</button>
65
</div>
66
<!-- Togglers -->
1
1
xxxxxxxxxx
1
//Initialize it with JS to make it instantly visible
2
3
const slimInstance = new mdb.Sidenav(document.getElementById('sidenav-4'));
4
slimInstance.show();
5
6
document.getElementById('slim-toggler').addEventListener('click', () => {
7
slimInstance.toggleSlim();
8
})
Console errors: 0