Dev Helpers
← Back

Breadcrumb trail component

Import and render <BreadcrumbTrailComponent /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/BreadcrumbTrailComponent.tsx

export default function BreadcrumbTrailComponent({
  links = [
    { label: "Guide", href: "/guide" },
    { label: "About", href: "/about" },
  ],
  current = "/guide",
}: { links?: { label: string; href: string }[]; current?: string } = {}) {
  return (
    <nav aria-label="Breadcrumb">
      <ol>
        {links.map((l, i) => (
          <li key={l.href}>
            {i === links.length - 1 ? (
              <span aria-current="page">{l.label}</span>
            ) : (
              <a href={l.href}>{l.label}</a>
            )}
          </li>
        ))}
      </ol>
    </nav>
  );
}