Skip to content
Thrum

Breadcrumb

The trail from the top of the site to the page being read, so a reader can see where they are and step back up. Pass the trail as items, or compose the parts yourself. For moving between sibling views use tabs; for the levels of a page header, put this in the page header's breadcrumb slot.

Install

npx shadcn@latest add https://thrumui.dev/r/breadcrumb.json

Adds components/ui/breadcrumb.tsx and installs @base-ui/react@1.9.0. Nothing else in your project changes.

import { Breadcrumb } from "@/components/ui/breadcrumb";

Automatically installs icons chevron-right and more-horizontal from the icon set.

Data shape

Type
type BreadcrumbEntry = {
  label: string;
  href?: string; // the last entry is the current page and needs none
};
Sample
const TRAIL = [
  { label: "Acme", href: "/" },
  { label: "Workspaces", href: "/workspaces" },
  { label: "Storefront", href: "/workspaces/storefront" },
  { label: "Reports", href: "/workspaces/storefront/reports" },
  { label: "Checkout latency" },
];

Props

PropTypeDefaultDescription
Breadcrumb: itemsreadonly BreadcrumbEntry[]–The trail from the top level to the current page, in order. The last entry is drawn as the current page. Use it instead of children.
Breadcrumb: maxItemsnumber–With items: the most entries shown at once, 2 or more. A longer trail keeps its first entry and its last ones, and the middle moves into a menu behind an ellipsis button. Without it nothing is folded.
Breadcrumb: separator"chevron" | "slash"Default "chevron"With items: the mark between entries.
Breadcrumb: classNamestring–Extra classes for the nav element, merged last.
Breadcrumb: ...propsComponentProps<"nav">–Every other nav attribute. aria-label is Breadcrumb unless you set another.
BreadcrumbListComponentProps<"ol">–The ordered list. It wraps onto more lines when the trail is wider than its container.
BreadcrumbItemComponentProps<"li">–One entry. It holds a link, the page or the ellipsis.
BreadcrumbLinkComponentProps<"a">–A link to a page higher up. A name wider than 192 pixels is cut with an ellipsis, and title carries the full text when the child is a string.
BreadcrumbPageComponentProps<"span">–The current page: text with aria-current="page", cut the same way.
BreadcrumbSeparatorComponentProps<"li">–The mark between two entries. A chevron by default; pass children for another mark. Hidden from screen readers.
BreadcrumbEllipsis: labelstringDefault "Show hidden pages"The name of the ellipsis button.
BreadcrumbEllipsis: childrenReactNode–BreadcrumbEllipsisItem elements: the button then opens them in a menu. With no children it is a plain mark that reads More.
BreadcrumbEllipsisItemComponentProps<"a">–One hidden entry in the menu. It is a link, and following it closes the menu.

Motion and sound

Motion

  • A link's colour changes over 150 ms on hover.
  • The menu of hidden entries fades in and grows from 96% to full size over 150 ms, from the corner at the button. Closing plays it backwards.
  • Reduced motion: colours change and the menu appears at once.

Sound

Silent. This component makes no sound.

Accessibility

  • It follows the WAI-ARIA breadcrumb pattern: a nav landmark named Breadcrumb that holds an ordered list of links, with aria-current="page" on the last entry.
  • Separators are hidden from screen readers. The list itself gives the order.
  • The ellipsis is a button named Show hidden pages. It opens a menu of links, built on the menu button pattern.
  • A name cut with an ellipsis keeps its full text in title, and a screen reader reads the full text either way.
  • The current page is told apart by its weight and its text colour as well as by aria-current.
  • Under a glass material the menu is translucent. Its tint keeps the text at 4.5 to 1 over any page.
KeysAction
TabMove through the links and the ellipsis button. The current page is text and is skipped.
EnterOn a link: follow it.
Enter / Space / ↓On the ellipsis button: open the menu, with its first entry highlighted.
↓ / ↑In the menu: move the highlight. Past the end it wraps.
Home / EndIn the menu: move to the first or last entry.
A to ZIn the menu: move to the next entry that starts with the typed letters.
EnterIn the menu: follow the highlighted link and close the menu.
EscClose the menu. Focus returns to the ellipsis button.

Source

components/ui/breadcrumb.tsx
"use client";

import { Fragment, type ComponentProps, type ReactNode } from "react";
import { Menu as MenuPrimitive } from "@base-ui/react/menu";

import { cn } from "@/lib/utils";
import { ChevronRightIcon } from "@/components/icons/chevron-right";
import { MoreHorizontalIcon } from "@/components/icons/more-horizontal";

export type BreadcrumbEntry = {
  /** The page's name. */
  label: string;
  /** Where it leads. The last entry is the current page and needs none. */
  href?: string;
};

export type BreadcrumbProps = ComponentProps<"nav"> & {
  /** The trail from the top level to the current page, in order. Use it instead of children; the last entry is the current page. */
  items?: readonly BreadcrumbEntry[];
  /** With `items`: the most entries shown at once, 2 or more. A longer trail keeps its first entry and its last ones and folds the middle into a menu. */
  maxItems?: number;
  /** With `items`: the mark between entries. */
  separator?: "chevron" | "slash";
};

const FOCUS = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
// A long name is cut with an ellipsis. Its full text stays in `title`.
const LABEL = "block max-w-48 truncate rounded-sm";
const text = (children: ReactNode) => (typeof children === "string" ? children : undefined);

/**
 * The trail from the top of the site to the current page. Compose it from the parts below, or pass `items`
 * and let `maxItems` fold a long trail. It is a `<nav>` named "Breadcrumb" holding an ordered list.
 */
export function Breadcrumb({ items, maxItems, separator = "chevron", className, children, ...props }: BreadcrumbProps) {
  let trail = children;
  if (items) {
    // The first entry and the last ones stay; what lies between goes behind the ellipsis.
    const keep = Math.max(2, Math.floor(maxItems ?? items.length));
    const fold = items.length > keep;
    const hidden = fold ? items.slice(1, items.length - (keep - 1)) : [];
    const shown = fold ? [items[0], ...items.slice(items.length - (keep - 1))] : items;
    const mark = <BreadcrumbSeparator>{separator === "slash" ? "/" : undefined}</BreadcrumbSeparator>;
    trail = (
      <BreadcrumbList>
        {shown.map((entry, i) => (
          // The position is the key: two entries of a trail may share a name.
          <Fragment key={i}>
            {i > 0 && mark}
            {i === 1 && fold && (
              <>
                <BreadcrumbItem>
                  <BreadcrumbEllipsis>
                    {hidden.map((entry, j) => (
                      <BreadcrumbEllipsisItem key={j} href={entry.href}>
                        {entry.label}
                      </BreadcrumbEllipsisItem>
                    ))}
                  </BreadcrumbEllipsis>
                </BreadcrumbItem>
                {mark}
              </>
            )}
            <BreadcrumbItem>
              {i === shown.length - 1 ? <BreadcrumbPage>{entry.label}</BreadcrumbPage> : <BreadcrumbLink href={entry.href}>{entry.label}</BreadcrumbLink>}
            </BreadcrumbItem>
          </Fragment>
        ))}
      </BreadcrumbList>
    );
  }
  return (
    <nav data-slot="breadcrumb" aria-label="Breadcrumb" className={cn("min-w-0", className)} {...props}>
      {trail}
    </nav>
  );
}

/** The ordered list. It wraps onto more lines in a narrow container. */
export function BreadcrumbList({ className, ...props }: ComponentProps<"ol">) {
  return <ol data-slot="breadcrumb-list" className={cn("flex flex-wrap items-center gap-x-1.5 gap-y-1 text-sm text-muted-foreground", className)} {...props} />;
}

/** One entry: it holds a `BreadcrumbLink`, a `BreadcrumbPage` or a `BreadcrumbEllipsis`. */
export function BreadcrumbItem({ className, ...props }: ComponentProps<"li">) {
  return <li data-slot="breadcrumb-item" className={cn("inline-flex max-w-full min-w-0 items-center", className)} {...props} />;
}

/** A link to a page higher up. A name longer than 192 pixels is cut, and its full text is in `title`. */
export function BreadcrumbLink({ className, title, children, ...props }: ComponentProps<"a">) {
  return (
    <a
      data-slot="breadcrumb-link"
      title={title ?? text(children)}
      className={cn(LABEL, "text-foreground/75 underline-offset-4 transition-[color] duration-150 ease-out hover:text-foreground hover:underline motion-reduce:transition-none", FOCUS, className)}
      {...props}
    >
      {children}
    </a>
  );
}

/** The current page: text, not a link, marked with `aria-current="page"`. */
export function BreadcrumbPage({ className, title, children, ...props }: ComponentProps<"span">) {
  return (
    <span data-slot="breadcrumb-page" aria-current="page" title={title ?? text(children)} className={cn(LABEL, "font-medium text-foreground", className)} {...props}>
      {children}
    </span>
  );
}

/** The mark between two entries: a chevron, or whatever you pass as children ("/"). Screen readers skip it. */
export function BreadcrumbSeparator({ className, children, ...props }: ComponentProps<"li">) {
  return (
    <li data-slot="breadcrumb-separator" role="presentation" aria-hidden="true" className={cn("inline-flex flex-none items-center text-foreground/55", className)} {...props}>
      {children ?? (
        <ChevronRightIcon size={14} className="rtl:rotate-180" />
      )}
    </li>
  );
}

export type BreadcrumbEllipsisProps = ComponentProps<"button"> & {
  /** The button's name for screen readers. */
  label?: string;
};

const DOTS = <MoreHorizontalIcon size={16} />;

/**
 * Three dots that stand for the entries left out. With `BreadcrumbEllipsisItem` children it is a button that opens them
 * in a menu; with none it is a plain mark.
 */
export function BreadcrumbEllipsis({ label = "Show hidden pages", className, children, ...props }: BreadcrumbEllipsisProps) {
  if (!children) {
    return (
      <span data-slot="breadcrumb-ellipsis" className={cn("grid size-7 place-items-center", className)}>
        {DOTS}
        <span className="sr-only">More</span>
      </span>
    );
  }
  return (
    <MenuPrimitive.Root>
      <MenuPrimitive.Trigger
        data-slot="breadcrumb-ellipsis"
        aria-label={label}
        className={cn(
          "grid size-7 cursor-pointer place-items-center rounded-md transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground motion-reduce:transition-none",
          FOCUS,
          className,
        )}
        {...props}
      >
        {DOTS}
      </MenuPrimitive.Trigger>
      <MenuPrimitive.Portal>
        <MenuPrimitive.Positioner sideOffset={4} align="start" className="z-50 outline-none">
          <MenuPrimitive.Popup
            data-slot="breadcrumb-menu"
            data-surface="floating"
            className={cn(
              "max-h-(--available-height) max-w-64 min-w-36 origin-(--transform-origin) overflow-y-auto overscroll-contain rounded-lg border bg-popover p-1 text-popover-foreground shadow-md outline-none",
              "transition-[opacity,scale] duration-150 ease-out data-ending-style:scale-[0.96] data-ending-style:opacity-0 data-starting-style:scale-[0.96] data-starting-style:opacity-0 motion-reduce:transition-none",
            )}
          >
            {children}
          </MenuPrimitive.Popup>
        </MenuPrimitive.Positioner>
      </MenuPrimitive.Portal>
    </MenuPrimitive.Root>
  );
}

/** One hidden entry in the ellipsis menu. It is a link; following it closes the menu. */
export function BreadcrumbEllipsisItem({ className, ...props }: MenuPrimitive.LinkItem.Props) {
  return (
    <MenuPrimitive.LinkItem
      data-slot="breadcrumb-ellipsis-item"
      closeOnClick
      className={cn(
        "flex min-h-8 cursor-default items-center rounded-sm px-2.5 py-1.5 text-sm [overflow-wrap:anywhere] outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground",
        className,
      )}
      {...props}
    />
  );
}

Files and dependencies

Adds
components/ui/breadcrumb.tsx
Packages
@base-ui/react@1.9.0
Brings along
Nothing
Icons
chevron-rightmore-horizontal

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor