Skip to content
English

How it works

A <nav> with one non-wrapping <ol>; separators sit inside each <li> and are aria-hidden, so the item count matches the visible levels. Every level is a pill: links get a hover pill, the current page is weight 600 in the body colour. When there are more levels than maxItems the middle folds into a round “…” chip (it turns ink while open) that opens a menu (absolute, no portal). When space runs short, short names stay put and longer ones shrink and truncate, with the full text in title.

Use it for

  • Pages three or more levels deep, where people need to know where they are and jump up in one step.
  • In a top bar title position (size sm) or above the page title in the content area.
  • Admin pages that go from a list to a detail and a sub-detail: it offers more than a single “Back” button.

Look elsewhere when

  • One or two levels: the page title is enough.
  • Steps in a flow (details, review, payment): use a step indicator; a breadcrumb shows hierarchy, not order.
  • Switching between pages on the same level: use tabs or a side navigation.
  • The main way back on narrow phone screens: use the title bar's back arrow.

Usage

import { useNavigate } from 'react-router-dom'
import { Breadcrumb } from './Breadcrumb.jsx'

// Items with href are links; the last item is the current page and needs no href.
// Five levels exceed the default of 4 slots, so the middle two fold into "…"
export function FileCrumb() {
  return (
    <Breadcrumb
      items={[
        { label: 'Home', href: '/' },
        { label: 'Documents', href: '/documents' },
        { label: 'Projects', href: '/documents/projects' },
        { label: 'Travel plans', href: '/documents/projects/travel' },
        { label: 'Lisbon itinerary' },
      ]}
    />
  )
}

// Client-side routing: keep href (right-click and Ctrl / Cmd-click still open a new tab), navigate on a plain click
export function RouterCrumb({ trail }) {
  const navigate = useNavigate()
  return (
    <Breadcrumb
      size="md"
      items={trail.map((t) => ({
        key: t.path,
        label: t.name,
        href: t.path,
        onClick: (e) => {
          if (e.metaKey || e.ctrlKey) return
          e.preventDefault()
          navigate(t.path)
        },
      }))}
    />
  )
}

Props

PropTypeDefaultWhat it does
itemsArray<{ key?, label, href?, onClick?, icon? }>—Levels from outermost to innermost. href renders an <a>, onClick alone a <button>, neither plain text. The last item is the current page and not clickable.
separatorReactNode'/'Separator, decorative only (aria-hidden). You can pass “›” or an SVG that uses currentColor.
size'sm' | 'md''sm'Font 13 / 14px and pill height 28 / 32px. Use sm in a top bar.
maxItemWidthnumber160Widest an item may be, in px. Longer text is truncated and shows in full on hover.
maxItemsnumber4Most slots shown (“…” counts as one), at least 3. With more levels it keeps the first item and the last maxItems − 2, and folds the rest into a “…” menu.
labelstring'Breadcrumb'Accessible name of the navigation region.
labelsobject—Replaces built-in text (more: (count) => string, the name of the “…” button). Shallow-merged over the English defaults.
...restHTMLAttributes<HTMLElement>—Other attributes (className, style) go to the root <nav>. Use --ds-breadcrumb-z for the folded menu's z-index (default 30).

Accessibility

  • The structure is <nav aria-label="Breadcrumb"><ol>…</ol></nav>; separators are aria-hidden and not read as “slash”.
  • The last item has aria-current="page" and is not clickable; it is also heavier (600), so colour is not the only cue.
  • Items with href are real links and onClick-only items are buttons; Tab moves through them and Enter activates, with a visible focus ring (an outline in forced-colors mode).
  • The “…” button is named “Show N hidden levels” (replaceable through labels), with aria-haspopup="menu", aria-expanded and aria-controls; the menu uses role="menu" and menuitem.
  • Enter, Space or Down opens the menu on the first item, Up on the last; inside, arrows loop, Home / End jump, and Esc closes only the menu and returns focus to the button.
  • On touch, hit areas grow to 44px while the look stays compact. With reduced motion the menu only fades in and the current page does not slide.

Motion

The folded menu grows out of the “…” chip in 200ms ease-out (scale 0.96 and 4px) and leaves in 140ms ease-in. When the current page changes it slides in 6px from the left over 240ms; nothing moves on first paint. Hover pills take 160ms and a press scales to 0.96; menu highlights have no transition.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

Breadcrumb.jsxbreadcrumb.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Navigation
Dock bar comes with Pro. Its preview shows once you unlock it.