Script

// Create the menu toggle
var toggle = new Toggle({
  blur: true,
  buttonClass: 'menu-toggle',
  buttonClassExpanded: 'menu-toggle-active',
  targetSelector: '.menu'
})

// Create accordion sections within menu
var accordion = new Toggle({
  buttonClassExpanded: 'toggle-btn-active',
  buttonSelector: 'a',
  parentClass: 'toggle-parent',
  targetSelector: '.menu ul ul'
})

HTML

<button>
  <span class="label-inactive">
    <i class="fa fa-bars" aria-hidden="true"></i>
    Menu
  </span>
  <span class="label-active">
    <i class="fa fa-times" aria-hidden="true"></i>
    Close
  </span>
</button>

<nav class="menu">
  <ul>
    <li>
      <a href="#">Pie</a>
      <ul>
        <li><a href="#">Apple Pie</a></li>
        <li>
          <a href="#">Cherry Pie</a>
          <ul>
            <li><a href="#">With Pastry Crust</a></li>
            <li><a href="#">With Graham Cracker Crust</a></li>
          </ul>
        </li>
        <li><a href="#">Pumpkin Pie</a></li>
        <li><a href="#">Chocolate Pie</a></li>
      </ul>
    </li>
    <li>
      <a href="#">Cake</a>
      <ul>
        <li>
          <a href="#">Vanilla Cake</a>
          <ul>
            <li><a href="#">With Vanilla Icing</a></li>
            <li><a href="#">With Chocolate Icing</a></li>
            <li><a href="#">With Sprinkles</a></li>
          </ul>
        </li>
        <li><a href="#">Chocolate Cake</a></li>
        <li><a href="#">Fruit Cake</a></li>
      </ul>
    </li>
    <li><a href="#">Ice Cream</a></li>
  </ul>
</nav>

CSS

/* Hide collapsed */
[aria-expanded="false"] {
  display: none;
}

/* Fixed navbar position */
body {
  padding-top: 50px;
}
.navbar {
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
}

/* Fixed menu position */
.menu {
  animation: slide-in-from-left 0.3s ease;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 50px;
}

/* Off-canvas menu animation */
@keyframes slide-in-from-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Add icon to parents */
.toggle-parent > a::after {
  content: '\f107'; /* Font Awesome 'angle-down' */
  display: inline-block;
  font-family: 'FontAwesome';
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
}

/* Flip the icon */
.toggle-parent > a.toggle-btn-active::after {
  transform: rotate(180deg);
}

/* Toggle button labels */
.menu-toggle .label-active {
  display: none;
}
.menu-toggle-active .label-active {
  display: block;
}
.menu-toggle-active .label-inactive {
  display: none;
}