<nav class="cap-breadcrumb" aria-label="Breadcrumb" id="bc-long">
<ol class="cap-breadcrumb-list">
<li class="cap-breadcrumb-item"><a class="cap-breadcrumb-link" href="#media">Media library</a></li>
<li class="cap-breadcrumb-item"><a class="cap-breadcrumb-link" href="#campaign" id="bc-long-link">Autumn 2026 community garden field survey photographs from the east park sites</a></li>
<li class="cap-breadcrumb-item"><span class="cap-breadcrumb-page" aria-current="page" id="bc-long-page">IMG_4821 north bed of the community garden at dawn, plot 3 of 12, photographed after eighteen hours of steady rain, the second visit of the spring survey</span></li>
</ol>
</nav>
A long trail folded in the HTML: the middle levels are links in a popover
The trail, first level to current page. Fewer than two levels renders nothing: a hub has no trail to show.
maxItems
number
Keep the first level and the last (maxItems - 1); the rest fold into a popover of links.
minItems
number
The fewest levels that draw a trail (2 by default). A site whose trail leaves out the home page, which its header already links, passes its structured data's minimum less one, so the page and its BreadcrumbList agree.
Draw a level's link with the app's router link: receives the class and the content.
Functions
Function
Signature
Does
foldedLevels
(count: number, max: number): number[]
Which levels fold: none unless the trail is longer than max and at least two levels would go (one level is no shorter than the button that replaces it). The first level and the last max - 1 stay. Returns the positions that fold, a run in the middle.
Folds a trail now. Returns a function that puts the levels back, or null when nothing folds.
enhance
(root?: ParentNode): () => void
Attaches every [data-cap="breadcrumb"] under root not yet attached: folds a trail that has data-max-items, and attaches the popover of a folded item. Returns a function that detaches them (a folded trail is put back).
Parts and data attributes
Class
Is
.cap-breadcrumb
the root
.cap-breadcrumb-ellipsis
a part
.cap-breadcrumb-item
a part
.cap-breadcrumb-link
a part
.cap-breadcrumb-list
a part
.cap-breadcrumb-more
a part
.cap-breadcrumb-more-link
a part
.cap-breadcrumb-page
a part
State
Read from
:focus-visible
the platform
:hover
the platform
:visited
the platform
[aria-current="page"]
an attribute
[aria-expanded="true"]
an attribute
Accessibility
Key
Does
Tab, Shift+Tab
Moves through the links and the folded-levels button in order; the current page is not a stop
Enter
Follows the focused link
Enter, Space on the folded-levels button
Opens the popover; focus moves to its first link
Tab, Shift+Tab in the popover
Moves between its links; tabbing past the last closes it
Esc
Closes the popover; focus returns to the button
A nav named "Breadcrumb" (use another name if a page has two) holding an ol. The current page is aria-current="page".
The folded button is named for what it does ("Show 2 more levels"); it has aria-haspopup="dialog" and aria-expanded. The popover is a dialog named "More levels".
Link text 4.5:1 on the page; the current page 4.5:1; the separator is decorative.
Each link and the button are at least var(--target) tall and wide. Forced colors draw the separator in CanvasText.