Drawerr is a mobile menu component that's simple and has no dependency on jQuery. It easily slides in with css animations(good for performance) when the hamburger button is clicked. Drawerr supports multi-level navigation so it's not hiding menu items( good for UX ).
- Multilevel support
- Slide direction( left or right )
- CSS animations( good for performance )
- Hamburger included
- Vanilla js, no jQuery
- Overridable sass variables
- browser support
Tested on real browsers with BrowserStack.
Use a service like polyfill.io
npm install drawerr --save
yarn add drawerr
drawerr/
└── dist/
└── drawerr.css
└── drawerr.js
Include CSS file inside the
<link rel="stylesheet" href="dist/drawerr.css">
Include JS file before the closing body tag
<script src="dist/drawerr.js"></script>
<button class="toggleDrawer">
<span></span>
<span></span>
<span></span>
</button>
Basic html is as follows:
<nav id="drawer" class="drawerr--init">
<ul>
<li>
<span class="section-title active">Gezus</span>
<ul>
<li>
<a class="active" href="#">rebum</a>
<ul>
<li><a class="active" href="#">case novum</a></li>
<li><a href="#">iisque</a></li>
</ul>
</li>
<li><a href="#">vix purto</a></li>
</ul>
</li>
<li>
<span class="section-title">quodsi</span>
<ul>
<li><a href="#">nullam</a></li>
<li>
<a href="#">corpora philosophia</a>
<ul>
<li>
<a href="#">mallan</a>
</li>
<li>
<a href="#">rebum</a>
<ul>
<li><a href="#">case novum</a></li>
<li>
<a href="#">iqtario</a>
<ul>
<li><a href="#">faari</a></li>
<li><a href="#">elissee</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<nav>
new drawerr().init(args);
Drawerr container selector
default: #drawerr
Btn selector which contains the hamburger
default: .toggleBtn
Menu text under the hamburger
default MENU
Navbar selector to determine the offset height for drawerr to slide in
default: header
Direction where drawerr comes from
default:left
Drawerr fires off events when it opens (drawerr-open
) or closes (drawerr-close
) the menu.
document.addEventListener('drawerr-open', function(){
// do something
});
NOTE: the active class should be rendered or set via backend
- Testing with browserstack
- More options based on the needs