webdevpuneet.com

Bootstrap Breadcrumb Trail with Dropdown Overflow — Free Snippet

Bootstrap Breadcrumb Trail with Dropdown Overflow · Navigation · Plain HTML, CSS & JS · Live preview

CategoryNavigation

Copy & paste

Source Code

<div class="container py-5">
  <p class="text-muted small mb-3">Click "+ Add level" a few times to grow the trail past 4 segments and watch the middle ones collapse into a "…" dropdown.</p>
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb bsbc-trail" id="bsbcTrail">
      <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
      <li class="breadcrumb-item"><a href="javascript:void(0)">Docs</a></li>
      <li class="breadcrumb-item"><a href="javascript:void(0)">Guides</a></li>
      <li class="breadcrumb-item active" aria-current="page">Getting Started</li>
    </ol>
  </nav>
  <button class="btn btn-sm btn-outline-dark" id="bsbcAdd">+ Add level</button>
  <button class="btn btn-sm btn-outline-secondary" id="bsbcReset">Reset</button>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Real Bootstrap 5.3 breadcrumb and Dropdown components, loaded from the actual CDN
Automatically collapses middle segments into a "…" dropdown once the trail exceeds 4 levels
Rebuilds the visible/hidden split from scratch on every change — never drifts out of sync
First and last two segments always stay visible, the ones a visitor most needs to see
Dropdown list of hidden segments uses Bootstrap's real Dropdown, not a custom popover
Works at any trail depth — the collapse logic has no hardcoded segment count

About this UI Snippet

Bootstrap Breadcrumb Trail with Dropdown Overflow — HTML, CSS & JavaScript

Screenshot of the Bootstrap Breadcrumb Trail with Dropdown Overflow snippet rendered live

A breadcrumb trail five or six levels deep stops being useful — it wraps, it crowds the page, and the first and last segments (the ones a visitor actually cares about) get lost in the middle. This snippet uses real Bootstrap 5.3's .breadcrumb component and rebuilds it every time a segment is added: once there are more than four segments, everything except the first and the last two collapses into a single "…" item using Bootstrap's real Dropdown component, so the trail always stays exactly four visible items wide no matter how deep the real path goes.

The render function is intentionally non-incremental — it removes any existing overflow dropdown and rebuilds the visible/hidden split from scratch on every change, which is what guarantees the collapsed trail can never drift out of sync with the actual path as levels are added or removed.

Step by step

How to Use

  1. 1
    Load the snippetClick the snippet in the sidebar Library tab. The preview loads a 4-segment breadcrumb.
  2. 2
    Add a levelClick "+ Add level" — a 5th segment appears, and the middle segments collapse into a "…" dropdown.
  3. 3
    Open the dropdownClick the "…" — Bootstrap's real Dropdown component shows the hidden middle segments as links.
  4. 4
    Add more levelsKeep clicking "+ Add level" — the dropdown's hidden list grows while the visible trail stays exactly four items.
  5. 5
    ResetClick "Reset" to return to the original 4-segment trail.

Real-world uses

Common Use Cases

Documentation and file-browser style navigation
Deep folder or doc hierarchies routinely exceed four levels — this keeps the trail usable instead of wrapping across two lines.
Learning the breadcrumb-overflow pattern
A concrete implementation of a well-known UX pattern (used in macOS Finder, GitHub, and many admin panels) built on real Bootstrap components.
E-commerce category breadcrumbs
Deeply nested product categories (Home > Electronics > Audio > Headphones > Wireless > ...) benefit from the same collapse behavior.
Admin panels with nested resource views
Reuse this pattern for breadcrumbs in a CMS or dashboard where resources can be nested arbitrarily deep.

Got questions?

Frequently Asked Questions

Real Bootstrap 5.3 — the "…" overflow item uses the actual Dropdown component via data-bs-toggle="dropdown", the same component used for any standard Bootstrap dropdown menu.

Once the trail has more than 4 segments. Change the "4" comparisons in the render() function to adjust that threshold.

No — render() recomputes which segments are hidden every time it runs, from whatever the current trail actually contains, so it's always accurate rather than a stale snapshot.

Yes — the breadcrumb-item and dropdown-item anchors already exist; set their href to real URLs (or wire click handlers to your router) instead of javascript:void(0).

Yes — the collapse logic has no hardcoded maximum; however many segments exist beyond the first and last two all get folded into the same overflow dropdown.

Yes. While the Bootstrap Breadcrumb Trail with Dropdown Overflow snippet gives you one pattern to copy, the free Responsive Navbar Builder at webdevpuneet.com/navbar-builder/ designs a whole navigation bar: logo, links and dropdown menus, a mobile hamburger menu (dropdown panel, slide-in drawer or full screen) and a scroll effect (sticky, shrink, hide on scroll or transparent). It has six presets, a live preview that runs the real code, and exports HTML + CSS + vanilla JS, React, Tailwind, Vue 3 or Angular — or you can click Fork & Edit to keep editing it in My Code.