Skip to content
← Components

Breadcrumb

Breadcrumb with thoughtful defaults, semantic styling, and editable source.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/breadcrumb.json

Use it

Scroll horizontally for long lines
"use client";
import { Breadcrumb } from "@/components/jez-ui/ui/breadcrumb";

export default function Example() {
  return (
    <>
      <Breadcrumb
        items={[
          { label: "Library", href: "/components" },
          { label: "Foundations", href: "/components?category=foundations" },
          { label: "Breadcrumb" },
        ]}
      />
    </>
  );
}

Compose your own

These styled parts are included in the same install. Use children to build your layout; add className only when you want an override.

Scroll horizontally for long lines
import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator } from "@/components/jez-ui/ui/breadcrumb";
Read the composition guide →

Props & types

Scroll horizontally for long lines
React.ComponentProps<"nav"> & {
  items?: { label: React.ReactNode; href?: string }[];
}

Source

View 2 source files

registry/ui/breadcrumb.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { cn } from "./utils";
export function Breadcrumb({
  items,
  children,
  className,
  ...props
}: React.ComponentProps<"nav"> & {
  items?: { label: React.ReactNode; href?: string }[];
}) {
  return (
    <nav
      aria-label="Breadcrumb"
      className={cn("text-sm", className)}
      {...props}
    >
      {items ? (
        <BreadcrumbList>
          {items.map((i, n) => (
            <React.Fragment key={n}>
              {n > 0 && <BreadcrumbSeparator />}
              <BreadcrumbItem>
                {i.href ? (
                  <BreadcrumbLink href={i.href}>{i.label}</BreadcrumbLink>
                ) : (
                  <BreadcrumbPage>{i.label}</BreadcrumbPage>
                )}
              </BreadcrumbItem>
            </React.Fragment>
          ))}
        </BreadcrumbList>
      ) : (
        children
      )}
    </nav>
  );
}
export function BreadcrumbList({
  className,
  ...props
}: React.ComponentProps<"ol">) {
  return (
    <ol
      className={cn(
        "flex list-none flex-wrap items-center gap-2 p-0",
        className,
      )}
      {...props}
    />
  );
}
export function BreadcrumbItem({
  className,
  ...props
}: React.ComponentProps<"li">) {
  return (
    <li
      className={cn("inline-flex items-center gap-2", className)}
      {...props}
    />
  );
}
export function BreadcrumbLink({
  asChild = false,
  className,
  ...props
}: React.ComponentProps<"a"> & { asChild?: boolean }) {
  const Comp = asChild ? Slot.Root : "a";
  return (
    <Comp
      className={cn("text-muted-foreground hover:text-foreground", className)}
      {...props}
    />
  );
}
export function BreadcrumbPage({
  className,
  ...props
}: React.ComponentProps<"span">) {
  return (
    <span
      aria-current="page"
      className={cn("text-foreground", className)}
      {...props}
    />
  );
}
export function BreadcrumbSeparator({
  children = "/",
  className,
  ...props
}: React.ComponentProps<"li">) {
  return (
    <li
      role="presentation"
      aria-hidden
      className={cn("text-muted-foreground", className)}
      {...props}
    >
      {children}
    </li>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

Dependencies

radix-ui@1.6.7 · clsx@2.1.1 · tailwind-merge@3.5.0

Accessibility & behaviour

Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.

Read the accessibility and performance guide →