Skip to content

React Breadcrumb

A responsive React breadcrumb whose middle items fold into a menu when space runs out, and unfold again when there is room.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/breadcrumb.json

Four items fit.

Collapses to fit

Drag the slider: middle items fold into the “…” menu (arrow keys, typeahead and Escape work inside it) and come back as the row widens. The last item is the current page, with aria-current="page".

Container width
100

Files to copy

5 folders · 6 files · 4 packages
From theme/src/
  • components/breadcrumb/
  • hooks/{use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, popup-a11y.ts, popup-motion.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/breadcrumb.jsonRegistry item: breadcrumb. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Styles

A glass pill, slash and dot separators, a small size, and maxItems to always collapse long trails.

renderLink renders every link through your router, including the links inside the collapse menu. Every string the component adds is a prop.

PropTypeDefaultDescription
items (required)BreadcrumbItem[]NoneThe trail, root first. The last item is the current page.
separatorReactNode"chevron"Between items: the presets "chevron", "slash" or "dot", or any node (rendered decoratively).
collapse"auto" | "never""auto""auto" folds middle items into a menu when the trail does not fit; "never" wraps instead.
maxItemsnumberno limitAlways collapse when there are more items than this.
itemsBeforenumber1Items always shown before the "…" menu.
itemsAfternumber1Items kept after the "…" when maxItems collapses (width-driven collapse keeps at least 1).
renderLink((item: BreadcrumbItem) => ReactElement)NoneRender every link as your router's link: (item) => <Link to={item.href!} />.
variant"glass" | "plain""plain"Picks a "plain" text trail or a "glass" pill.
size"sm" | "md""md"Sets the text and row size.
labelsPartial<BreadcrumbLabels>defaultBreadcrumbLabelsAny UI string (i18n): nav and more. Give each breadcrumb on a page its own nav. Every other string, for translation: labels={{ nav: "…" }}; omitted keys keep the English of defaultBreadcrumbLabels. All 2 keys of BreadcrumbLabels are listed in the key table under the props table.
classNamestringNoneAdds extra classes to the <nav>.
PropTypeDefaultDescription
labelReactNodeNoneSets the text shown for the item.
hrefstringNoneLink target. Without one (and for the last item) it is plain text.
iconReactNodeNoneShows an icon before the label.
iconOnlybooleanfalseShow only the icon; the label stays for screen readers.
textValuestringNonePlain text for menu typeahead when the label is not a string.
renderReactElementNoneElement for this one link (overrides renderLink).
idstringNoneStable key that identifies the item between renders.

Keyboard

KeysAction
Tab/Shift + TabMove through the links and the "…" button.
EnterFollow a link, or open the collapsed-items menu.
Arrow keys, typeahead, EscapeWork inside the menu as in any menu.

Accessibility

  • A <nav aria-label="Breadcrumb"> with an ordered list; the last item has aria-current="page". Give a second breadcrumb on the page its own labels.nav.
  • Separators are hidden from assistive tech. An icon-only item keeps its label for screen readers.
  • The "…" menu lists the hidden pages as real links.

All exports on this page

  • Breadcrumb — Where the current page sits in the hierarchy.
  • defaultBreadcrumbLabels — The English strings of Breadcrumb ("Breadcrumb" for the landmark, "Show N hidden pages" for the "…" button).

When to use Breadcrumb

  • Use it as a collapsible breadcrumb on a documentation or e-commerce page that sits several levels deep, such as Home, Products, Shoes, Running, so people can jump back to any ancestor without using the browser's Back button.
  • Use maxItems with itemsBefore and itemsAfter for deeply nested file or category trees, where you always want the root and the current page visible and the middle folded into a menu.
  • The collapse is measured before paint, so it suits responsive layouts where the same trail must fit a phone header and a wide desktop header without a flash of overflow.
  • Skip it for linear multi-step flows such as checkout; Stepper shows progress and state there, and breadcrumbs describe site hierarchy rather than the order of tasks.
  • Pair it with Navbar or Vertical nav for primary navigation, with Menu behavior already built in for the folded items, and with a page heading and Button actions below the trail.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .