Breadcrumb
Displays the path to the current resource using a hierarchy of links.
Installation
Install the following dependencies:
Set up the token layer and the StyleX compiler, if you have not already. See
Installation. The breadcrumb also needs interop.css,
which sizes the separator and ellipsis icons.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
Usage
Composition
Basic
A trail of links ending in the current page.
Custom separator
Pass children to BreadcrumbSeparator to replace the chevron.
Dropdown
Put a DropdownMenu inside a BreadcrumbItem to branch off a segment.
Collapsed
Use BreadcrumbEllipsis to stand in for the segments a long trail hides.
BreadcrumbEllipsis is aria-hidden and has no accessible name. When it
triggers a menu, put an aria-label on the control around it.
Link component
Pass a router link through render on BreadcrumbLink. BreadcrumbLink then
applies its styles and props to your link instead of an a.
API reference
Pass render to replace a part's element or compose it with another component.
Every part takes xstyle and className.
Breadcrumb
The nav landmark. It renders aria-label="breadcrumb" and carries no styling
of its own, so a list can be rendered without it.
BreadcrumbLink
Renders an a and accepts its props.
| Prop | Type | Default |
|---|---|---|
render | React.ReactNode | <a /> |
BreadcrumbSeparator
Renders an li marked role="presentation".
| Prop | Type | Default |
|---|---|---|
children | React.ReactNode | <ChevronRight /> |
breadcrumbStyles
The style map behind the component, exported so the same look can go on any element.
| Key | Description |
|---|---|
list | The wrapping row, its type and colour |
item | One segment's inline box |
link | The hover colour and the focus ring |
page | The current segment |
separator | The separator's icon size |
ellipsis | The ellipsis box and its icon size |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="breadcrumb" | the nav | Targets the landmark from a parent |
data-slot="breadcrumb-list" | the list | Targets the row |
data-slot="breadcrumb-item" | an item | Targets one segment |
data-slot="breadcrumb-link" | a link | Present on whatever render produces |
data-slot="breadcrumb-page" | the last item | Also carries aria-current="page" |
data-slot="breadcrumb-separator" | the separator | Also role="presentation" and aria-hidden |
data-slot="breadcrumb-ellipsis" | the ellipsis | Also role="presentation" and aria-hidden |
The separator and the ellipsis carry the carbon-icons class and set
--carbon-icon-size, which is how interop.css sizes the icon inside each.