Components

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

Do
  • 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 BreadcrumbPage for the current page, as text rather than a link.
  • Fold the middle steps into BreadcrumbEllipsis when the trail is too long for the header.
Don’t
  • 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

A <nav> landmark around an <ol>. Other props go to the list.

PropTypeDefault
aria-label
Names the landmark for screen readers.
string'Breadcrumb'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

One step of the trail, as an <li>.

PropTypeDefault
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

A step the user can go back to.

PropTypeDefault
href
Where the link goes.
string—
render
Replaces the <a>, e.g. render={<Link to="/" />}.
ReactElement | function—
icon
Icon shown before the label, e.g. a team or project icon.
ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

The current page. Not a link; carries aria-current="page".

PropTypeDefault
icon
Icon shown before the label, e.g. a team or project icon.
ReactNode—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

Sits between two items. Hidden from screen readers.

PropTypeDefault
children
Replaces the chevron, e.g. with a slash.
ReactNodechevron
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

A … button that opens a dropdown of hidden steps. Put DropdownLinkItems inside, in trail order.

PropTypeDefault
aria-label
Names the button for screen readers.
string'Show hidden pages'
side
Side of the button to open on.
'top' | 'bottom' | 'left' | 'right''bottom'
align
Alignment along that side.
'start' | 'center' | 'end''start'
sx
StyleX styles merged after the built-in ones.
StyleXStyles—