← Components

Navigation

Breadcrumb

Where this page sits in a hierarchy. Chevrons, never lines; a long trail collapses its middle into … that unfolds on press.

Examples and variants

Collapsed middle

Press … to show all crumbs.

Example
function BreadcrumbCollapsed() {
  return (
    <Breadcrumb
      items={[
        { label: "Home", href: "#" },
        { label: "Projects", href: "#" },
        { label: "Northwind", href: "#" },
        { label: "Design", href: "#" },
        { label: "Tokens" },
      ]}
    />
  )
}

Spec drawing

Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.

Install

With the CLI

The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.

Terminal
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/breadcrumb.json

By hand

No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.

  1. Install the packages it uses.

    Terminal
    npm install lucide-react
  2. Copy this file to the same paths in your project. Imports use the @/ alias for your project root.

    • components/ui/breadcrumb.tsxbreadcrumb
      components/ui/breadcrumb.tsx
      "use client"
      
      import * as React from "react"
      import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
      
      /*
        Breadcrumb: where this page sits. Separators are chevrons, never lines.
        With more than `max` items the middle collapses into "…"; pressing it
        unfolds the hidden crumbs.
      */
      type Crumb = { label: string; href?: string }
      
      function Breadcrumb({ items, max = 4, className, ...props }: React.ComponentProps<"nav"> & { items: Crumb[]; max?: number }) {
        const [expanded, setExpanded] = React.useState(false)
        const collapse = !expanded && items.length > max
        const visible: (Crumb | "more")[] = collapse ? [items[0], "more", ...items.slice(-(max - 2))] : items
        return (
          <nav aria-label="Breadcrumb" data-slot="breadcrumb" className={className} {...props}>
            <ol className="flex flex-wrap items-center gap-1 text-sm text-muted-foreground">
              {visible.map((item, index) => {
                const last = index === visible.length - 1
                return (
                  <li key={item === "more" ? "more" : item.label} className="breadcrumb-item inline-flex items-center gap-1">
                    {item === "more" ? (
                      <button
                        type="button"
                        aria-label="Show all crumbs"
                        onClick={() => setExpanded(true)}
                        className="liquid-press inline-flex size-6 items-center justify-center rounded-(--shape-sm) outline-none hover:bg-(--breadcrumb-collapse-container-hover) active:bg-(--breadcrumb-collapse-container-pressed) focus-visible:shadow-(--focus-ring)"
                      >
                        <MoreHorizontalIcon className="size-(--size-icon-sm)" />
                      </button>
                    ) : last ? (
                      <span aria-current="page" className="font-medium text-foreground">
                        {item.label}
                      </span>
                    ) : (
                      <a href={item.href} className="hit-target breadcrumb-link rounded-(--shape-xs) outline-none hover:text-foreground focus-visible:shadow-(--focus-ring)">
                        {item.label}
                      </a>
                    )}
                    {!last ? <ChevronRightIcon aria-hidden className="breadcrumb-chevron size-(--size-icon-sm) text-ink-subtle" /> : null}
                  </li>
                )
              })}
            </ol>
          </nav>
        )
      }
      
      export { Breadcrumb }
      export type { Crumb }
      

Imports

What the examples on this page import:

Imports
import {
import { AppBar } from "@/components/ui/app-bar"
import { Badge } from "@/components/ui/badge"
import { Breadcrumb } from "@/components/ui/breadcrumb"
import { Button } from "@/components/ui/button"
import { DropdownMenuItem } from "@/components/ui/dropdown-menu"
import { Fab } from "@/components/ui/fab"
import { Navigation, NavigationItem } from "@/components/ui/navigation"
import { Pagination } from "@/components/ui/pagination"
import { SplitButton } from "@/components/ui/split-button"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@/components/ui/toolbar"

Anatomy

  1. 1Crumb · A link; the last crumb is the current page.
  2. 2Separator · Chevron icon.
  3. 3More · Collapsed middle.

Props

PropTypeDefaultDescription
items{ label: string; href?: string }[]—From root to current.
maxnumber4Collapse the middle above this.

Tokens

Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.

This utility has no component tokens; it uses semantic tokens directly.

TokenPoints toLightDark

Motion

TriggerWhat happensTokens
HoverThe link lifts 1px and the chevron after it nudges.--duration-fast

Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.

Accessibility

  • nav with aria-label=Breadcrumb; the current crumb has aria-current=page.

Usage

Do

  • Use for nested pages.

Don’t

  • Don't use on flat sites.

Code

components/ui/breadcrumb.tsx
"use client"

import * as React from "react"
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"

/*
  Breadcrumb: where this page sits. Separators are chevrons, never lines.
  With more than `max` items the middle collapses into "…"; pressing it
  unfolds the hidden crumbs.
*/
type Crumb = { label: string; href?: string }

function Breadcrumb({ items, max = 4, className, ...props }: React.ComponentProps<"nav"> & { items: Crumb[]; max?: number }) {
  const [expanded, setExpanded] = React.useState(false)
  const collapse = !expanded && items.length > max
  const visible: (Crumb | "more")[] = collapse ? [items[0], "more", ...items.slice(-(max - 2))] : items
  return (
    <nav aria-label="Breadcrumb" data-slot="breadcrumb" className={className} {...props}>
      <ol className="flex flex-wrap items-center gap-1 text-sm text-muted-foreground">
        {visible.map((item, index) => {
          const last = index === visible.length - 1
          return (
            <li key={item === "more" ? "more" : item.label} className="breadcrumb-item inline-flex items-center gap-1">
              {item === "more" ? (
                <button
                  type="button"
                  aria-label="Show all crumbs"
                  onClick={() => setExpanded(true)}
                  className="liquid-press inline-flex size-6 items-center justify-center rounded-(--shape-sm) outline-none hover:bg-(--breadcrumb-collapse-container-hover) active:bg-(--breadcrumb-collapse-container-pressed) focus-visible:shadow-(--focus-ring)"
                >
                  <MoreHorizontalIcon className="size-(--size-icon-sm)" />
                </button>
              ) : last ? (
                <span aria-current="page" className="font-medium text-foreground">
                  {item.label}
                </span>
              ) : (
                <a href={item.href} className="hit-target breadcrumb-link rounded-(--shape-xs) outline-none hover:text-foreground focus-visible:shadow-(--focus-ring)">
                  {item.label}
                </a>
              )}
              {!last ? <ChevronRightIcon aria-hidden className="breadcrumb-chevron size-(--size-icon-sm) text-ink-subtle" /> : null}
            </li>
          )
        })}
      </ol>
    </nav>
  )
}

export { Breadcrumb }
export type { Crumb }