Navigation
Breadcrumb
A trail of links showing where the current page sits in the hierarchy of the site, from the top level down to the page itself. Use it on pages more than one level deep, so the user can go back up.
Each item renders its own separator; tk:breadcrumb.separator is only written to place one by hand.
Nothing to show
Three items in a row with a chevron between them. Home and Orders are links, slightly dimmed until hovered; the last one is plain text in a medium weight, announced as the current page.
From an array #
Each entry is a label, or an array with the props and attributes of a tk:breadcrumb.item. The last entry is marked as the current page for you.
Nothing to show
Rendering from data #
Every crumb but the last is a link; the last is text marked as the current page. When the data already has the shape of the items (label, href), pass it to items instead of looping.
Nothing to show
Separator #
separator takes an icon name and applies to every item. An item can have its own, as an icon name or as a slot with any content: here a slash follows Home and a dot follows Docs.
Nothing to show
Icons and custom content #
The first item is a link with only an icon, the second has a badge after its label. The third has nothing but slot content, so that content is placed in the list item as it is, and the link is entirely yours.
Nothing to show
Any icon as separator #
separator takes any icon name, not only slash.
Nothing to show
Sizes and scale #
size sets the font size and the size of icons and separators, from xs to 3xl; scale moves only the font one or two steps.
Nothing to show
Buttons instead of links #
With action (a Livewire method) an item is a button, here to move through folders without leaving the page. current marks the open folder.
Nothing to show
Long labels #
A label that does not fit is cut with an ellipsis, keeping the separators and the other items visible.
Nothing to show
Customization #
Classes go to the <nav>; list: reaches the <ol> and item: every item from items, with the item prefixes (item:separator:class).
Nothing to show
Reference
tk:breadcrumb
└── tk:breadcrumb.item
└── tk:breadcrumb.separator
tk:breadcrumb
| Prop | Type | Default | Description |
|---|---|---|---|
items |
array | Collection | null |
The items to render. Each entry is a string, used as the label, or an array of tk:breadcrumb.item props and attributes (label, href, icon, class...). |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Sets the font size and the size of the icons and separators. |
scale |
string | null |
smallest, small, large or largest. Moves the font size one or two steps down or up, leaving the icons as size sets them. |
separator |
string | slot | mdi:chevron-right |
The icon between the items. slash shows a slash (tabler:slash). |
Slots
| Slot | Description |
|---|---|
| default | The items. They come after the ones from items when both are given. |
separator |
Content in place of the separator icon, for the items rendered from items. |
Prefixes
| Prefix | Goes to |
|---|---|
list: |
The <ol>. |
item: |
Each item rendered from items, as props and attributes of tk:breadcrumb.item. A value set in the item itself wins; classes are added. |
tk:breadcrumb.item
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string | slot | null |
The item text, translated. The default slot does the same without translating. |
current |
bool | string | from the URL | Marks a link as the current page. true sets aria-current="page", a string sets that value (step, location...), false never marks it. |
separator |
string | slot | inherited | The icon after this item, or any content in its place. |
size |
string | inherited | Sets the size of this item's icon and separator. |
size and separator are inherited from the breadcrumb. Also accepts the element props (icon, iconTrailing, badge, suffix...), and what makes an element a link or a button: href, route, external, tooltip, action...
Slots
| Slot | Description |
|---|---|
| default | The item content, in place of the label prop. |
label |
The item content, as markup. |
separator |
Content in place of the separator icon after this item. |
Prefixes
| Prefix | Goes to |
|---|---|
container: |
The <li>. |
separator: |
The separator. |
icon: |
The icon. |
content: |
The element wrapping the text. |
tk:breadcrumb.separator
| Prop | Type | Default | Description |
|---|---|---|---|
icon |
string | slot | mdi:chevron-right |
The icon name (slash for a slash), or any content. |
Customization
Classes and attributes on tk:breadcrumb go to the <nav>. On tk:breadcrumb.item they go to the link (or the <span>, when the item has no href), not to the list item around it. To reach the other elements, prefix the attribute (listed in the Reference above).
The other prefixes of the element props work too (icon-trailing:, suffix:, badge:...), and item: can carry any of the item's prefixes: item:container:class, item:separator:class.
Nothing to show
Accessibility
Follows the WAI-ARIA breadcrumb pattern. The root is a <nav> labelled "Breadcrumb" (translated; pass aria-label to change it) holding an ordered list, and the current page carries aria-current="page". The separators have aria-hidden="true", and the one after the last item is not displayed.
There is no keyboard interaction beyond that of the links. An item without href is not in the tab order.
| Key | Action |
|---|---|
| Tab | Moves to the next link in the trail. |
| Enter | Follows the focused link. |
Behavior notes
- With no
itemsand an empty slot, the breadcrumb renders nothing, not even the<nav>. - The last entry of
itemsalways getsaria-current="page", link or not, even when items written in the slot come after it. Items written in the slot do not: a link is marked only when itshrefis exactly the current URL (a query string in thehrefhas to match too), and a last item that is plain text needsaria-current="page"on it, as in the first example. currentonly acts on an item that is a link or a button. On an item withouthrefit does nothing; usearia-currentthere.- Inside Livewire, the link pointing to the page stays marked as current across updates.
- An item with slot content and no other prop or attribute (
separator,sizeandcontainer:attributes aside) puts the content straight into the<li>, with no wrapping element. A direct<a>or<button>in it still gets the dimmed look of the other links. item:attributes and theseparatorslot of the breadcrumb only reach the items rendered fromitems. Theseparatorprop with an icon name reaches the items written in the slot as well.- The default chevron and
slashare mirrored in right-to-left pages. Any other icon, and separator content from a slot, is shown as it is. - A long label is cut with an ellipsis when it does not fit, and the trail wraps onto more lines when there is no room for all the items.
content:classon an item replaces the class that cuts the label instead of adding to it: includetruncatein it to keep the ellipsis.- The values of an
itemsentry are escaped: HTML in a label shows as text. For markup in an item, write it in the slot. - When the slot content starts with a
<nav>of your own, it is rendered as it is: the breadcrumb adds no wrapper and its props and attributes are ignored.