Script
var toggle = new Toggle({
blur: true,
buttonClass: 'toggle-btn',
buttonClassExpanded: 'toggle-btn-active',
parentClass: 'toggle-parent'
})
HTML
<button>
Choose a Dessert
<i class="fa fa-angle-down" aria-hidden="true"></i>
</button>
<nav class="toggle">
<ul>
<li><a href="#">Pie</a></li>
<li><a href="#">Cake</a></li>
<li><a href="#">Ice Cream</a></li>
</ul>
</nav>
CSS
/* Hide collapsed */
[aria-expanded="false"] {
display: none;
}
/* Menu position */
.toggle-parent {
position: relative;
}
.toggle {
left: 0;
position: absolute;
top: 100%;
width: 100%;
}
/* Flip the icon */
.toggle-btn i {
transition: transform 0.3s ease;
}
.toggle-btn-active i {
transform: rotate(180deg);
}