CSS Collapsible Breadcrumbs
Long breadcrumb trails that hide middle levels behind an ellipsis button that opens a small menu.
<nav class="collapse-crumbs" aria-label="Breadcrumb">
<ol>
<li><a href="#">Home</a></li>
<li>
<details>
<summary aria-label="Show 2 more levels">…</summary>
<ul>
<li><a href="#">Projects</a></li>
<li><a href="#">2026</a></li>
</ul>
</details>
</li>
<li><a href="#">Launch</a></li>
<li aria-current="page">Assets</li>
</ol>
</nav>
.collapse-crumbs ol {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
margin: 0;
padding: 0;
list-style: none;
color: #0f172a;
font: 500 14px system-ui, sans-serif;
}
.collapse-crumbs ol > li + li::before {
content: "›";
margin-right: 6px;
color: #94a3b8;
}
.collapse-crumbs li {
display: flex;
align-items: center;
}
.collapse-crumbs a {
color: #64748b;
text-decoration: none;
}
.collapse-crumbs a:hover {
color: #0f172a;
text-decoration: underline;
}
.collapse-crumbs details {
position: relative;
}
.collapse-crumbs summary {
padding: 0 8px;
border-radius: 6px;
background: #e2e8f0;
color: #334155;
line-height: 24px;
list-style: none;
cursor: pointer;
}
.collapse-crumbs summary::-webkit-details-marker {
display: none;
}
.collapse-crumbs summary:hover,
.collapse-crumbs details[open] summary {
background: #cbd5e1;
}
.collapse-crumbs ul {
position: absolute;
top: calc(100% + 6px);
left: 0;
z-index: 1;
min-width: 130px;
margin: 0;
padding: 6px;
list-style: none;
border-radius: 10px;
background: #ffffff;
box-shadow: 0 0 0 1px #0f172a14, 0 10px 24px -8px #0f172a33;
}
.collapse-crumbs ul a {
display: block;
padding: 7px 10px;
border-radius: 6px;
}
.collapse-crumbs ul a:hover {
background: #f1f5f9;
text-decoration: none;
}
.collapse-crumbs a:focus-visible,
.collapse-crumbs summary:focus-visible {
outline: 2px solid #2563eb;
outline-offset: 2px;
}
About this CSS Collapsible Breadcrumbs
This CSS Collapsible Breadcrumbs is 86 lines of pure CSS (1.4 KB) with no JavaScript and no dependencies. It uses box shadows, Flexbox and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#0f172a#94a3b8#64748b#e2e8f0#334155#cbd5e1#ffffff#0f172a14#0f172a33#f1f5f9
How to use this collapsible breadcrumbs
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.collapse-crumbsclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.