Materializecss is a web framework for creating decent looking web app and components without using css.
Sidenav is a javascript component of materialize css, To use the sidenav in your projects you need to include CSS and javascript file of materializecss in your project.you should also include jquery file, if you want to use the sidenav through jquery, if not, then it's completely okay.
Dependency
- materializecss css
- materializecss js
- jquery (optional)
HTML Markup
<nav> <!-- navbar content here --> </nav> <ul id="slide-out" class="sidenav"> <li><div class="user-view"> <div class="background"> <img src="images/office.jpg"> </div> <a href="#user"><img class="circle" src="images/yuna.jpg"></a> <a href="#name"><span class="white-text name">John Doe</span></a> <a href="#email"><span class="white-text email">[email protected]</span></a> </div></li> <li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li> <li><a href="#!">Second Link</a></li> <li><div class="divider"></div></li> <li><a class="subheader">Subheader</a></li> <li><a class="waves-effect" href="#!">Third Link With Waves</a></li> </ul> <a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
Initialization Scripts
document.addEventListener('DOMContentLoaded', function() { var elems = document.querySelectorAll('.sidenav'); var instances = M.Sidenav.init(elems, options); }); // Initialize collapsible (uncomment the lines below if you use the dropdown variation) // var collapsibleElem = document.querySelector('.collapsible'); // var collapsibleInstance = M.Collapsible.init(collapsibleElem, options); // Or with jQuery $(document).ready(function(){ $('.sidenav').sidenav(); });