Overview
Reference usage
A navigation trail that shows the current page's position in a hierarchy.
Usage
Set monospace: true on individual items that carry identifiers. The item keeps the monospace font in the trail, the phone back label, and any menu or default current-page popover that repeats its label.
Phone form
Below collapseBelow (640px by default) the inline phone form shows a back link labelled with the parent, the trail's separator, then the current page, which truncates first. The back chevron hangs, so its ink starts on the trail's edge, the edge a page title below it shares. The back link is a real link with the accessible name "Back to Runs" (backLabel words it), at least 44px tall. A trail with one entry shows just that entry, and collapseBelow={false} keeps the whole trail at every width and renders no back link.
phoneLayout defaults to "inline". Set phoneLayout="stacked" to put the back link above the current page and align both to the trail's start edge. The <nav> exposes data-cinder-phone-below and data-cinder-phone-layout as styling hooks.
The phone form is chosen in CSS, so it is already on the first paint: server HTML holds both forms, the whole trail and the back link, and a viewport query shows one of them before any script runs. The hidden form is display: none, so the accessibility tree holds one form at a time, with one navigation landmark and one current page. The rules for the default 640px are in the component's stylesheet. Any other length brings the same rules in a small <style> element inside the trail, so a page whose Content Security Policy refuses inline styles keeps the default collapseBelow.
A long current page
Give the last item a popover and it draws as a bordered button with a chevron that truncates its label with an ellipsis at 300px. popover: true fills the popover with the full label, which is what a long chat title needs; a snippet fills it with anything else.
When to use
- Surfacing where the user sits inside a deep, nested hierarchy.
- Letting the user jump back to any ancestor view in one click.
- A server-rendered page that must paint its phone form before script runs: both forms are in the server HTML, and CSS exposes one at a time.
- Setting identifier labels in monospace per item and using phoneLayout to give the back link its own line on a narrow screen.
- Switching between sibling sections at the same level — use navigation-bar or tabs.
- Showing an ordered task progression — use steps instead.
Examples
Basic breadcrumbs
Navigation trail with the final entry as the current page.
Custom separator
Override the default "/" separator with any string or snippet.
Phone form and a long current page
Below collapseBelow (640px by default) the trail is a back link labelled with the parent ("Back to Chat") and the current page, which truncates first. A popover on the current page draws it as a button that truncates at 300px and keeps the full title in the popover. This example sets collapseBelow wide enough to show the phone form at any width.
Props
Name | Type | Default | Description |
|---|---|---|---|
items required | BreadcrumbItem[] | Ordered list of breadcrumb entries from root to current page. | |
separator | text | '/' | Custom separator between entries. Defaults to "/". |
label | text | 'Breadcrumb' | Accessible name for the nav landmark. Defaults to "Breadcrumb". |
collapseBelow | text | '640px' | Viewport width below which the trail collapses to its phone form: a back link labelled with
the parent ("Runs") followed by the current page, which truncates first. A trail with a
single entry shows just that entry. A simple CSS length such as '640px', or false to
always show the whole trail. Default '640px'. The form is chosen in CSS, so it is already on
the first paint: the server HTML holds both forms and a viewport query exposes one at a time.
A length other than the default brings its rules in a small inline <style>. |
phoneLayout | 'inline' | 'stacked' | 'inline' | Arrange the phone back link and current page on one line or stack them. Default 'inline'. |
backLabel | text | 'Back to {label}' | Accessible name of the phone back link; {label} is replaced by the parent's label.
Default "Back to {label}". |
maxVisible | number | How many ancestors (every entry before the current page) show before the rest fold into a
leading "…" button that lists them in a menu. Left unset, a trail shows every ancestor until
its container is narrower than 24rem, where one ancestor shows (the current page's parent):
an ancestor that cannot show its full first word is left out with its separator, never
squeezed to a fragment. A number applies at every width, and 0 folds every ancestor. | |
overflowLabel | text | 'Show earlier pages' | Accessible name of the "…" button that opens the hidden ancestors. Default
"Show earlier pages". |
onOverflowNavigate | (item: BreadcrumbItem, event: MouseEvent) => void | Called when a link in the hidden-ancestors menu is clicked, with the entry it opens. Call
event.preventDefault() to open the page without a reload, as an application's router does.
The menu renders in a portal, outside the trail's own element, so a click handler on the
trail never sees these links. |