Breadcrumb
A hierarchy trail that collapses its middle levels into an expandable ellipsis.
AI prompt
Build a breadcrumb navigation for a six-level path (Home / Library / Design / Components / Navigation / Breadcrumb) inside a nav element with aria-label="Breadcrumb" and an ordered list. Use chevron separators drawn with CSS and aria-hidden. When there are more than four levels, show only Home, an ellipsis button, and the last two levels. The ellipsis is a button with aria-label "Show hidden levels" and aria-expanded; clicking it reveals the hidden levels with a 160ms fade and 30ms stagger, then moves focus to the first revealed link. The last item is plain text with aria-current="page". Links are muted and underline on hover. Truncate very long labels with an ellipsis at 18ch. Disable animation for prefers-reduced-motion.About this pattern
Definition
A horizontal trail of links that shows where the current page sits in a hierarchy, from the top level down to the current page. When the trail is long, the middle levels collapse into an ellipsis button that expands them.
Purpose & UX principles
- Shows location and offers a quick way up several levels at once.
- It is secondary navigation: it complements, but does not replace, the main navigation.
- The last item is the current page; it is not a link and carries
aria-current="page".
Interaction states
- Link: muted, brightens on hover with an underline.
- Collapsed: ellipsis button with
aria-label="Show hidden levels"andaria-expanded="false". - Expanded: all levels visible, focus moves to the first revealed link.
- Current: bright text, not clickable.
Motion specification
- Revealed items fade in with a 30ms stagger, 160ms each.
- Reduced motion: items appear immediately.
Responsive behaviour
- On narrow screens keep only the first item, the ellipsis and the last two items.
- Use a chevron separator, not a slash, so screen readers are not given extra noise (mark separators
aria-hidden).
Code
<nav class="bc" aria-label="Breadcrumb">
<ol id="bc">
<li><a href="#">Home</a></li>
<li class="mid" hidden><a href="#">Library</a></li>
<li class="mid" hidden><a href="#">Design</a></li>
<li class="mid" hidden><a href="#">Components</a></li>
<li class="more"><button id="more" aria-label="Show hidden levels" aria-expanded="false">…</button></li>
<li><a href="#">Navigation</a></li>
<li><span aria-current="page">Breadcrumb</span></li>
</ol>
</nav>
<p class="note">Click the ellipsis to reveal the hidden levels.</p>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.bc ol{display:flex;align-items:center;flex-wrap:wrap;gap:2px;list-style:none;padding:12px 16px;border:1px solid var(--line);border-radius:14px;background:var(--surface)}
.bc li{display:flex;align-items:center;max-width:18ch}
.bc li+li::before{content:"";width:6px;height:6px;margin:0 10px;border-top:1.5px solid var(--muted);border-right:1.5px solid var(--muted);transform:rotate(45deg) scale(.8);flex:none}
.bc a,.bc span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.bc a{color:var(--muted);text-decoration:none}
.bc a:hover{color:var(--text);text-decoration:underline}
.bc [aria-current=page]{color:var(--text);font-weight:600}
.more button{background:var(--surface-2);border:1px solid var(--line);color:var(--text);border-radius:8px;padding:0 9px;height:26px;cursor:pointer;font:inherit}
.more button:focus-visible,.bc a:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}
.mid.show{animation:in .16s ease-out both;animation-delay:calc(var(--n)*30ms)}
.note{margin-top:14px;color:var(--muted);font-size:13px;text-align:center}
@keyframes in{from{opacity:0;transform:translateX(-6px)}}
@media (prefers-reduced-motion:reduce){.mid.show{animation:none}}const more=document.getElementById('more'),mids=[...document.querySelectorAll('.mid')];
more.addEventListener('click',()=>{
mids.forEach((li,i)=>{li.hidden=false;li.style.setProperty('--n',i);li.classList.add('show');});
more.closest('li').remove();
mids[0].querySelector('a').focus();
});One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Breadcrumb — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.bc ol{display:flex;align-items:center;flex-wrap:wrap;gap:2px;list-style:none;padding:12px 16px;border:1px solid var(--line);border-radius:14px;background:var(--surface)}
.bc li{display:flex;align-items:center;max-width:18ch}
.bc li+li::before{content:"";width:6px;height:6px;margin:0 10px;border-top:1.5px solid var(--muted);border-right:1.5px solid var(--muted);transform:rotate(45deg) scale(.8);flex:none}
.bc a,.bc span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.bc a{color:var(--muted);text-decoration:none}
.bc a:hover{color:var(--text);text-decoration:underline}
.bc [aria-current=page]{color:var(--text);font-weight:600}
.more button{background:var(--surface-2);border:1px solid var(--line);color:var(--text);border-radius:8px;padding:0 9px;height:26px;cursor:pointer;font:inherit}
.more button:focus-visible,.bc a:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}
.mid.show{animation:in .16s ease-out both;animation-delay:calc(var(--n)*30ms)}
.note{margin-top:14px;color:var(--muted);font-size:13px;text-align:center}
@keyframes in{from{opacity:0;transform:translateX(-6px)}}
@media (prefers-reduced-motion:reduce){.mid.show{animation:none}}
</style></head>
<body><div class="stage">
<nav class="bc" aria-label="Breadcrumb">
<ol id="bc">
<li><a href="#">Home</a></li>
<li class="mid" hidden><a href="#">Library</a></li>
<li class="mid" hidden><a href="#">Design</a></li>
<li class="mid" hidden><a href="#">Components</a></li>
<li class="more"><button id="more" aria-label="Show hidden levels" aria-expanded="false">…</button></li>
<li><a href="#">Navigation</a></li>
<li><span aria-current="page">Breadcrumb</span></li>
</ol>
</nav>
<p class="note">Click the ellipsis to reveal the hidden levels.</p>
</div>
<script>
const more=document.getElementById('more'),mids=[...document.querySelectorAll('.mid')];
more.addEventListener('click',()=>{
mids.forEach((li,i)=>{li.hidden=false;li.style.setProperty('--n',i);li.classList.add('show');});
more.closest('li').remove();
mids[0].querySelector('a').focus();
});
</script>
</body></html>