Breadcrumbs
The trail from the top of the app to the current page, for the app header. Steps in the middle can fold into a dropdown.
Usage
import {
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbPage,
BreadcrumbSeparator,
Breadcrumbs,
} from 'nyctoui/breadcrumbs'
<Breadcrumbs>
<BreadcrumbItem>
<BreadcrumbLink render={<Link to="/settings" />}>Settings</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Teams</BreadcrumbPage>
</BreadcrumbItem>
</Breadcrumbs>BreadcrumbLink renders an <a>; pass render={<Link to="…" />} for a router link. The trail pulls in by the crumbs’ padding, so the first label lines up with the text above and below it.
Good for
- The header of a file browser or a cloud storage app, from the drive down to the current folder.
- An admin panel several levels deep, such as Settings, Members, then one member.
- A product page in a large shop, showing the category it sits in.
- A docs site with nested sections, above the page title.
Anatomy
<Breadcrumbs>
<BreadcrumbItem>
<BreadcrumbLink />
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbEllipsis>
<DropdownLinkItem />
</BreadcrumbEllipsis>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage />
</BreadcrumbItem>
</Breadcrumbs>Examples
Basic
With icons
Collapsed from a list
BreadcrumbEllipsis is a Dropdown behind a … button; its children are the menu’s content. Here a long trail keeps its first step and last two, and folds the rest away.
Custom separator
A separator draws a chevron unless it is given children.
Best practices
- Put the trail above the page title, so people see where they are before they read.
- Use the same words as the pages they link to: “Settings”, not “Application settings page”.
- End the trail with
BreadcrumbPagefor the current page, as text rather than a link. - Fold the middle steps into
BreadcrumbEllipsiswhen the trail is too long for the header.
- Use breadcrumbs as the app’s only navigation. They go alongside a sidebar or a top bar.
- Show a trail on a top-level page that has nowhere to go back to.
- Let the trail grow past five steps. If the app is that deep, the structure needs flattening.
API reference
Breadcrumbs
A <nav> landmark around an <ol>. Other props go to the list.
| Prop | Type | Default |
|---|---|---|
aria-labelNames the landmark for screen readers. | string | 'Breadcrumb' |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BreadcrumbItem
One step of the trail, as an <li>.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BreadcrumbLink
A step the user can go back to.
| Prop | Type | Default |
|---|---|---|
hrefWhere the link goes. | string | — |
renderReplaces the <a>, e.g. render={<Link to="/" />}. | ReactElement | function | — |
iconIcon shown before the label, e.g. a team or project icon. | ReactNode | — |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BreadcrumbPage
The current page. Not a link; carries aria-current="page".
| Prop | Type | Default |
|---|---|---|
iconIcon shown before the label, e.g. a team or project icon. | ReactNode | — |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BreadcrumbSeparator
Sits between two items. Hidden from screen readers.
| Prop | Type | Default |
|---|---|---|
childrenReplaces the chevron, e.g. with a slash. | ReactNode | chevron |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BreadcrumbEllipsis
A … button that opens a dropdown of hidden steps. Put DropdownLinkItems inside, in trail order.
| Prop | Type | Default |
|---|---|---|
aria-labelNames the button for screen readers. | string | 'Show hidden pages' |
sideSide of the button to open on. | 'top' | 'bottom' | 'left' | 'right' | 'bottom' |
alignAlignment along that side. | 'start' | 'center' | 'end' | 'start' |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |