Skip to content

Breadcrumb with Overflow Dropdown

Tailwind CSS breadcrumb that collapses middle levels into an accessible dropdown when the trail is too long or too wide, and re-expands on resize.

Also known as: collapsible breadcrumb, breadcrumb overflow menu, responsive breadcrumb trail, truncated breadcrumb dropdown

Breadcrumb with Overflow Dropdown live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A responsive breadcrumb built with Tailwind CSS and a small vanilla JavaScript controller. Deep trails such as documentation sites, file managers, admin panels and design system docs keep the first level and the current page visible, while the levels in between collapse into a dropdown behind a dots button.

How it works

The root is a nav.bcd-trail with aria-label="Breadcrumb". Inside, the ol.bcd-list holds one li per level, each marked data-bcd-item, plus a hidden li.bcd-more that contains the .bcd-toggle button and an empty ul.bcd-menu. The last item is a span with aria-current="page".

On DOMContentLoaded the script runs a layout pass for every .bcd-trail. It shows all levels, adds the .bcd-measuring class so that no item may shrink, and then hides middle levels one by one, starting next to Home, while the list is wider than the bar (scrollWidth > clientWidth) or while more levels are visible than data-bcd-max-visible allows. Hidden levels are rebuilt as links inside .bcd-menu, each with a small .bcd-menu-depth tree line indented by its depth. A ResizeObserver repeats the pass whenever the width of the bar changes, so the trail expands again on wider screens. Without JavaScript all levels stay visible in one row.

Clicking .bcd-toggle opens or closes the menu and flips aria-expanded; the button turns solid violet through the aria-expanded: variant. Arrow Down opens the menu and focuses the first link, Arrow Up/Down, Home and End move between links, and Escape closes it and returns focus to the button. Clicking outside or tabbing away also closes it.

Customization

  • data-bcd-max-visible on .bcd-trail: the maximum number of levels shown before collapsing; remove it to collapse only when the trail does not fit.
  • bg-violet-600 on the aria-current="page" item: change the color of the current-page pill or use font-semibold text-slate-900 for a plain look.
  • The separator svg path m8 5 5 5-5 5: replace it with a slash (M13 4 7 16) for slash separators.
  • w-60 on .bcd-menu: widen the dropdown for long level names.
  • .bcd-menu a in style.css: change hover color, padding or font weight of the dropdown links.
  • .bcd-menu-depth in style.css: hide it with display: none for a flat list without tree lines.
  • rounded-2xl bg-white/90 on .bcd-trail: remove them for a borderless breadcrumb inside a page header.

Use cases

  • Documentation sites: long section paths keep the first level and current page visible while middle levels fold into a dropdown
  • File managers and cloud storage: deeply nested folder trails stay on one row and expand again when the window grows
  • Admin panels: users jump back to any parent screen from the dots menu, using the keyboard if they prefer
  • Design system docs: a collapsing trail avoids wrapping on narrow screens while still exposing every level

Accessibility

The trail is a nav landmark with an ordered list, and the current page uses aria-current="page". The dots button uses the disclosure pattern with aria-expanded and aria-controls; its visually hidden .bcd-label is updated to read, for example, "Show 3 hidden levels". Separators and icons are aria-hidden. All links and the button show violet focus outlines, and the menu animation is disabled under prefers-reduced-motion: reduce.

Usage notes

For several breadcrumbs on one page, give each .bcd-menu a unique id and point the toggle's aria-controls to it.

Breadcrumb with Overflow Dropdown at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Breadcrumbs
License
Free for personal and commercial use

Questions about this template

Can I use the Breadcrumb with Overflow Dropdown code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Breadcrumb with Overflow Dropdown – free Tailwind CSS breadcrumb template
Breadcrumb with Overflow Dropdown · free Tailwind CSS breadcrumb template

More Breadcrumbs

Arrow Breadcrumbs – free Pure CSS breadcrumb template

Arrow Breadcrumbs

Chevron-shaped breadcrumb steps cut with CSS clip-path, with an interlocking layout, a color ramp toward the current page and a compact dark variant. No JavaScript.

Breadcrumb with Schema.org Structured Data – free Bootstrap 5 breadcrumb template

Breadcrumb with Schema.org Structured Data

SEO-friendly Bootstrap 5 breadcrumb with BreadcrumbList microdata, a collapsible mobile path, a search result preview and a JSON-LD copy panel.

Breadcrumb with Icons – free Bootstrap 5 breadcrumb template

Breadcrumb with Icons

Bootstrap 5 breadcrumbs with a home icon, icons per level and custom chevron, slash or dot dividers that collapse middle levels on mobile.