Snippets Navigation

Bootstrap 5 Navbar with Auto-Scrolling Dropdown Menus

A pill navigation bar whose long dropdown menus scroll automatically as the pointer nears the top or bottom edge, with fade hints and native scrolling on touch.

Bootstrap 5 No jQuery Jun 2019 3K views

<section class="wdw-stage align-items-start">
  <div class="container" style="max-width: 920px; padding-top: 6vh">
    <div class="text-center mb-4">
      <span class="wdw-eyebrow">Navigation</span>
      <h2 class="wdw-heading h2 mt-1 mb-1">Hover-scroll dropdowns</h2>
      <p class="wdw-muted mb-0">Long menus scroll on their own as your pointer moves toward the top or bottom edge.</p>
    </div>
    <nav class="navbar navbar-expand-md wdw-card-sm px-3 py-2" aria-label="Product menus" id="scrollNav">
      <span class="navbar-brand d-md-none fw-bold mb-0">Product</span>
      <button class="navbar-toggler border-0 shadow-none ms-auto" type="button" data-bs-toggle="collapse" data-bs-target="#scrollNavMenu" aria-controls="scrollNavMenu" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
      <div class="collapse navbar-collapse" id="scrollNavMenu">
        <ul class="navbar-nav w-100 justify-content-between">
          <li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false" id="dd1">Analytics</a>
            <ul class="dropdown-menu wdw-scrollmenu" aria-labelledby="dd1" aria-label="Analytics menu">
              <li><h3 class="dropdown-header wdw-eyebrow px-3 pt-2">Reports and insights</h3></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3v18h18"/><path d="M7 15l4-4 3 3 5-6"/></svg></span><span><span class="d-block fw-semibold">Overview</span><small class="d-block text-body-secondary text-wrap">Traffic and revenue at a glance</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"/></svg></span><span><span class="d-block fw-semibold">Dashboards</span><small class="d-block text-body-secondary text-wrap">Build boards for every team</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z"/><path d="M14 3v4h4"/></svg></span><span><span class="d-block fw-semibold">Reports</span><small class="d-block text-body-secondary text-wrap">Scheduled PDF and CSV summaries</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"/><circle cx="10" cy="7" r="4"/></svg></span><span><span class="d-block fw-semibold">Segments</span><small class="d-block text-body-secondary text-wrap">Group visitors by behaviour</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4h18l-7 8v7l-4 2v-9z"/></svg></span><span><span class="d-block fw-semibold">Funnels</span><small class="d-block text-body-secondary text-wrap">Spot where people drop off</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2l10 5-10 5L2 7zM2 12l10 5 10-5M2 17l10 5 10-5"/></svg></span><span><span class="d-block fw-semibold">Cohorts</span><small class="d-block text-body-secondary text-wrap">Compare groups over time</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12A9 9 0 1 1 12 3v9z"/></svg></span><span><span class="d-block fw-semibold">Retention</span><small class="d-block text-body-secondary text-wrap">See who keeps coming back</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.7 21a2 2 0 0 1-3.4 0"/></svg></span><span><span class="d-block fw-semibold">Alerts</span><small class="d-block text-body-secondary text-wrap">Get pinged when metrics move</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4H3v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/></svg></span><span><span class="d-block fw-semibold">Exports</span><small class="d-block text-body-secondary text-wrap">Send raw data to your warehouse</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13 2L3 14h9l-1 8 10-12h-9z"/></svg></span><span><span class="d-block fw-semibold">Real-time</span><small class="d-block text-body-secondary text-wrap">Watch events as they happen</small></span></a></li>
            </ul></li>
          <li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false" id="dd2">Workspace</a>
            <ul class="dropdown-menu wdw-scrollmenu" aria-labelledby="dd2" aria-label="Workspace menu">
              <li><h3 class="dropdown-header wdw-eyebrow px-3 pt-2">Manage your team</h3></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2"/><circle cx="10" cy="7" r="4"/></svg></span><span><span class="d-block fw-semibold">Teams</span><small class="d-block text-body-secondary text-wrap">Invite people and set up groups</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="7.5" cy="15.5" r="4.5"/><path d="M21 2l-9.6 9.6M15.5 7.5l3 3L22 7l-3-3"/></svg></span><span><span class="d-block fw-semibold">Roles</span><small class="d-block text-body-secondary text-wrap">Fine-grained permissions</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 5h20v14H2zM2 10h20"/></svg></span><span><span class="d-block fw-semibold">Billing</span><small class="d-block text-body-secondary text-wrap">Plans, invoices and seats</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg></span><span><span class="d-block fw-semibold">Security</span><small class="d-block text-body-secondary text-wrap">SSO, 2FA and audit trail</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6"/></svg></span><span><span class="d-block fw-semibold">Preferences</span><small class="d-block text-body-secondary text-wrap">Defaults for your workspace</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span><span><span class="d-block fw-semibold">Activity</span><small class="d-block text-body-secondary text-wrap">Everything that changed, and when</small></span></a></li>
            </ul></li>
          <li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false" id="dd3">Developers</a>
            <ul class="dropdown-menu wdw-scrollmenu" aria-labelledby="dd3" aria-label="Developers menu">
              <li><h3 class="dropdown-header wdw-eyebrow px-3 pt-2">Build on the API</h3></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v15H6.5"/></svg></span><span><span class="d-block fw-semibold">API reference</span><small class="d-block text-body-secondary text-wrap">Every endpoint, with examples</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1 1"/><path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1-1"/></svg></span><span><span class="d-block fw-semibold">Webhooks</span><small class="d-block text-body-secondary text-wrap">Push events to your own URL</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 18l6-6-6-6M8 6l-6 6 6 6"/></svg></span><span><span class="d-block fw-semibold">SDKs</span><small class="d-block text-body-secondary text-wrap">Clients for the popular languages</small></span></a></li>
              <li><a class="dropdown-item d-flex align-items-center gap-3 py-2 px-3" href="#"><span class="wdw-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 17l6-6-6-6M12 19h8"/></svg></span><span><span class="d-block fw-semibold">CLI</span><small class="d-block text-body-secondary text-wrap">Script your workflow from a shell</small></span></a></li>
            </ul></li>
          <li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
        </ul>
      </div>
    </nav>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.