Breadcrumbs Beta
Shows people where they are in the site and lets them go back to a parent page. Put tg2Breadcrumbs<nav><ol>li[tg2BreadcrumbsItem]includesCurrentPage
Usage
Project a link into each item, usually an <a routerLink>queryParamsincludesCurrentPage
<nav tg2Breadcrumbs includesCurrentPage>
<ol>
<li tg2BreadcrumbsItem><a routerLink="/motors">First</a></li>
<li tg2BreadcrumbsItem><a routerLink="/motors/cars">Second</a></li>
<li tg2BreadcrumbsItem><a routerLink="/motors/cars/toyota">Third</a></li>
<li tg2BreadcrumbsItem>Current page</li>
</ol>
</nav>When not to use
Only use breadcrumbs for the page's own location, once per page. For a category path inside a card or a list item, use plain links: each tg2Breadcrumbs
Current page
By default no item is marked as the current page, as with tgBreadcrumbs
<!-- Ancestors only (the default): every item is a link, none is the current page -->
<nav tg2Breadcrumbs>
<ol>
<li tg2BreadcrumbsItem><a routerLink="/">Home</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property">Property</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/auckland">Auckland</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/auckland/rodney">Rodney</a></li>
</ol>
</nav> When the trail ends with the current page, set includesCurrentPagearia-current="page"
Truncation
Set truncatedtitle
The tg-light and tg-dark themes show "…" only, as tgBreadcrumbs
<nav tg2Breadcrumbs includesCurrentPage>
<ol>
<li tg2BreadcrumbsItem><a routerLink="/motors">Motors</a></li>
<li tg2BreadcrumbsItem truncated>
<a routerLink="/motors/cars" title="Cars & trucks">Cars & trucks</a>
</li>
<li tg2BreadcrumbsItem><a routerLink="/motors/cars/toyota">Toyota</a></li>
<li tg2BreadcrumbsItem>Corolla</li>
</ol>
</nav>Last item
The last item is always capped at 30 characters and "…", so a long page title can't take over the trail. It gets a titletruncatedtgBreadcrumbs
<nav tg2Breadcrumbs includesCurrentPage>
<ol>
<li tg2BreadcrumbsItem><a routerLink="/motors">Motors</a></li>
<li tg2BreadcrumbsItem><a routerLink="/motors/cars">Cars</a></li>
<!-- Shows "2019 Toyota Corolla GX Hatchba…" -->
<li tg2BreadcrumbsItem>2019 Toyota Corolla GX Hatchback 1.8L Automatic</li>
</ol>
</nav>Automatic
Set autoTruncate<nav><nav>truncated
An automatically truncated item gets a titletitle<nav>flex: 1<nav>
Drag the corner of the box to resize it.
<nav tg2Breadcrumbs autoTruncate>
<ol>
<li tg2BreadcrumbsItem><a routerLink="/">Home</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property">Property</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/residential">Residential</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/residential/sale">Sale</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/residential/sale/auckland">Auckland</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/residential/sale/auckland/north-shore-city">North Shore City</a></li>
<li tg2BreadcrumbsItem><a routerLink="/property/residential/sale/auckland/north-shore-city/browns-bay">Browns Bay</a></li>
</ol>
</nav> In a row, give the <nav>flex: 1<nav><nav>
<div class="header-row"> <!-- display: flex -->
<nav tg2Breadcrumbs autoTruncate class="header-row__trail"> <!-- flex: 1 -->
<ol>…</ol>
</nav>
<button tg2Button>Watchlist</button>
</div>Accessibility
makes thetg2Breadcrumbs a landmark labelled "Breadcrumb". Set<nav> on thearia-label to change the label.<nav>- You write the
and its<ol> items, so native list semantics are kept and screen readers announce each item's position, e.g. "item 2 of 4". An item that isn't directly inside an<li> throws an error.<ol> - With
, the last item getsincludesCurrentPage : project it as plain text, not a link. Without it, no item is marked, which is right for an ancestors-only trail where the current page isn't listed.aria-current="page" - The separator between items is
and not read out.aria-hidden - Links are always underlined in the tg2 themes, so they don't rely on colour alone. The tg-light and tg-dark themes underline them on hover, as
does.tgBreadcrumbs - A truncated item is still read in full by screen readers. A
tooltip only helps mouse users: keyboard and touch users only see the first 5 characters, so truncate sparingly. The last item is capped at 30 characters, with its full text in atitle .title
Element-selector components (<tg2-breadcrumbs><tg2-breadcrumbs-item><li><ol><ul>li[tg2BreadcrumbsItem]<li><ol>
The container directive is on the <nav><ol><li><nav>
API
nav[tg2Breadcrumbs]
Labels the <nav>data-tg-theme<nav>theme
| Property | Type | Default | Description |
|---|---|---|---|
includesCurrentPage | boolean | false | Marks the last item as the current page, with aria-current="page" |
autoTruncate | boolean | false | Keeps the trail on one line, truncating middle items from the left until it fits. Never truncates the first or last item. |
aria-label | string | 'Breadcrumb' | The landmark's name, read by screen readers. |
li[tg2BreadcrumbsItem]
Write items directly inside the <ol>li[tg2BreadcrumbsItem]includesCurrentPage
| Input | Type | Default | Description |
|---|---|---|---|
truncated | boolean | false | Shortens the projected link to its first 5 characters and "…" ("…" only in tg-light and tg-dark). Ignored on the last item, which is always capped at 30 characters instead (tg2 themes), on plain text, and on text with fewer than 6 characters. Screen readers still read the full text. |
Try every option interactively on the Code Example page.