|Kit

Breadcrumb

Polymorphic

A trail of links showing the current page's place in a hierarchy, with an auto-muted current crumb and router-link support.

Breadcrumb renders a trail of links showing the current page's place in a hierarchy — home → … → current page. It's a pure Server Component — no state, no "use client".

import { Breadcrumb } from "@42-central/ui-react/breadcrumb";

<Breadcrumb
  withHome={{ href: "/" }}
  data={[
    { label: "Repo", href: "/repo" },
    { label: "File" },
  ]}
/>;

Basic

The data form is the quickest way to use it — pass an array of crumbs. The last entry defaults to the current, non-interactive crumb unless another entry explicitly sets current; separators between crumbs are generated automatically, never placed by hand.

Code

<Breadcrumb
  withHome={{ href: '/' }}
  data={[
    { label: 'ui-react', href: '/ui-react' },
    { label: 'components', href: '/ui-react/components' },
    { label: 'breadcrumb.tsx' },
  ]}
/>
The current crumb is muted, not bolded

The last crumb renders muted and non-interactive (aria-current="page") — it isn't a link, so it's deliberately de-emphasized rather than made the visually strongest item. That's the inverse of some breadcrumb conventions; it's what this component's source design calls for.

Compound form

Drop to Breadcrumb.Root + Breadcrumb.Home/Breadcrumb.Item for full control over composition — same rendering as the data form, hand-written instead of generated.

Code

<Breadcrumb.Root>
  <Breadcrumb.Home href="/" />
  <Breadcrumb.Item href="/repo">Repo</Breadcrumb.Item>
  <Breadcrumb.Item current>File</Breadcrumb.Item>
</Breadcrumb.Root>

A step with no page of its own — a section without an index — is a Breadcrumb.Item with no href: it reads as part of the trail, in a link's colour, but it is plain text, with no underline on hover and no <a> to follow.

Code

<Breadcrumb.Root>
  <Breadcrumb.Home href="/" />
  <Breadcrumb.Item>Learn</Breadcrumb.Item>
  <Breadcrumb.Item current>Modules</Breadcrumb.Item>
</Breadcrumb.Root>

Icons

icons replaces Breadcrumb.Home's house through its home key, on the data form or on Breadcrumb.Root. A Breadcrumb.Home with children keeps them. The separator is the separator prop, any node, since it's often a character rather than an icon; flip a directional one with rtl:-scale-x-100. Your icons are drawn as given: add className={iconStroke} (from @42/ui-react) for the kit's 1.5px line.

Code

<Breadcrumb
  withHome={{ href: "/" }}
  icons={{ home: <Building2 className={cn(iconStroke, "size-4")} /> }}
  separator={<ChevronRight className="size-3.5 rtl:-scale-x-100" />}
  data={[{ label: "Campus", href: "/campus" }, { label: "Paris" }]}
/>

Truncation

The trail always fits its container, and it takes no JavaScript to do it: when space runs out, link crumbs ellipsize first — all the way down to a bare "…" — and the current crumb only starts shrinking once they can't give up any more. The home icon and separators never shrink. Hover or keyboard-focus a crumb to open it back up to its full label. Drag the corner of the box below to try it.

Code

<div className="w-[420px] max-w-full resize-x overflow-hidden p-1">
  <Breadcrumb
    withHome={{ href: '/' }}
    data={[
      { label: 'packages', href: '/packages' },
      { label: 'react', href: '/packages/react' },
      { label: 'components', href: '/packages/react/components' },
      { label: 'breadcrumb.test.tsx' },
    ]}
  />
</div>

The full label stays in the DOM, so screen readers always announce it. Inside a flex row (a header next to other controls), the breadcrumb's <nav> already carries min-w-0, so it shrinks with the row instead of pushing it wider.

Pass linkComponent to route every generated crumb through your framework's own Link instead of a plain <a>, so navigation stays client-side. It works on Breadcrumb/Breadcrumb.Root (the default for every crumb) or per-item (overrides just one):

import Link from "next/link";
import { Breadcrumb } from "@42-central/ui-react/breadcrumb";

<Breadcrumb
  linkComponent={Link}
  data={[{ label: "Repo", href: "/repo" }, { label: "File" }]}
/>;

Routers whose Link takes to instead of href (React Router) need a two-line local wrapper renaming the prop before passing it as linkComponent:

import { Link as RouterLink } from "react-router";

const Link = ({ href, ...props }: { href?: string }) => (
  <RouterLink to={href ?? "#"} {...props} />
);

For one-off composition, asChild (inherited from Ark) still works on any single Breadcrumb.Item/Breadcrumb.Home, and wins over linkComponent:

<Breadcrumb.Item asChild>
  <Link href="/repo">Repo</Link>
</Breadcrumb.Item>

Breadcrumb.Home puts its house icon inside an asChild link that has no children of its own, so a bare router link is enough:

<Breadcrumb.Home asChild>
  <Link href="/" />
</Breadcrumb.Home>

Back button

Every one of this component's source designs pairs it with a leading "back" icon-button — but that's a router/history action this kit has no opinion on, so it isn't part of Breadcrumb. Compose one next to it with ActionIcon:

Code

<div className="flex items-center gap-1">
  <ActionIcon variant="subtle" size="sm" radius="xs" aria-label="Back">
    <ChevronLeft aria-hidden />
  </ActionIcon>
  <Breadcrumb withHome={{ href: '/' }} data={[{ label: 'File' }]} />
</div>

Subcomponents

Prop

Type

Every part renders testId as data-testid on its own DOM node — see Testing.

API

Prop

Type

Breadcrumb.Root takes the same props except data/withHome — compose Breadcrumb.Home/Breadcrumb.Item as its children instead.

Prop

Type

Prop

Type

Accessibility

  • Renders <nav aria-label="Breadcrumb"> (override via aria-label) wrapping an <ol>.
  • The current/last crumb gets aria-current="page" and isn't focusable or a link.
  • Separators are decorative — aria-hidden, never announced.
  • Breadcrumb.Home defaults its accessible name to "Home" via aria-label. Without an href it isn't a link at all: it renders <span role="img" aria-label="Home">, since an <a> with no href is a generic element, where aria-label is prohibited and the name would be lost.

Changelog

v0.30.1
  • A Breadcrumb.Item with no href is plain text: no <a>, no underline on hover, and a Root linkComponent leaves it alone

    #497
v0.20.0
  • Swap any built-in icon through an icons map — icons={{ asc, desc }} on DataTable, icons={{ show, hide }} on PasswordInput; a key you leave out keeps the kit's icon, and a part's children still win

    #361
  • A Home crumb without an href renders as a named image, not a dead link

    #389
v0.18.0
  • asChild is a compile error on the data forms of Accordion, Tabs and Breadcrumb, on the ready-made Notification and on AppShell.Sidebar (their Root parts keep it)

    #294
  • Breadcrumb.Home asChild puts its house icon inside an empty link

    #288
v0.17.0
  • Crumbs truncate to fit the container, with CSS alone

    #264
v0.5.0
  • New Breadcrumb component

    #62

On this page