# Breadcrumb

> Trail of links showing where the current page sits in the site, ending in the page itself as plain text.

- Kind: ui · Category: Navigation · Interactivity: native
- Install: `npx shadcn@latest add @haze/breadcrumb`
- File: `src/components/haze/ui/breadcrumb.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/breadcrumb

## Use when
- Pages nested two or more levels deep, such as docs, shops or settings
- Letting readers jump back up the hierarchy in one click
- Long trails that must wrap on a narrow screen

## Avoid when
- A flat site with one level of pages
- Showing steps of a process; use stepper

## Alternatives
- [stepper](https://hazeui.com/ui/stepper.md)
- [tabs](https://hazeui.com/ui/tabs.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| items | `{ label: string; href?: string }[]` |  | yes | Trail from the top level down; the last item is the current page and is not a link. |
| label | `string` | "Breadcrumb" | no | Accessible name of the nav landmark. |
| class | `string` |  | no | Extra classes on the nav. |

## Accessibility
- The last item carries aria-current="page" and is plain text, so the reader is not offered a link to where they already are.
- An ordered list tells screen readers how many levels the trail has. It carries role="list" because Safari drops list semantics from lists without markers. The chevrons between items are aria-hidden.
- Long trails wrap onto more lines, and a single long label is cut with an ellipsis at 10 rem.
- Translate the label prop when the page is not in English, since it names the landmark.
- Key Tab: Move through the ancestor links

## Agent prompts

### Install and use

Install the Haze UI component "Breadcrumb" with `npx shadcn@latest add @haze/breadcrumb`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Breadcrumb from "@/components/haze/ui/breadcrumb.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/breadcrumb.md

### Customize with real content

Adapt the Haze breadcrumb ui for our product. Replace the demo values of these props with our real content: items, label, class. Keep the layout, the heading level rules and these accessibility details: The last item carries aria-current="page" and is plain text, so the reader is not offered a link to where they already are. An ordered list tells screen readers how many levels the trail has. It carries role="list" because Safari drops list semantics from lists without markers. The chevrons between items are aria-hidden. Long trails wrap onto more lines, and a single long label is cut with an ellipsis at 10 rem. Translate the label prop when the page is not in English, since it names the landmark. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using breadcrumb, check it fits: use it when pages nested two or more levels deep, such as docs, shops or settings; letting readers jump back up the hierarchy in one click; long trails that must wrap on a narrow screen. Avoid it when a flat site with one level of pages; showing steps of a process; use stepper. Alternatives: @haze/stepper, @haze/tabs.

## Example requests that should lead here
- Add a breadcrumb Home, Docs, Components, Alert above the title
- Show a three-level trail for a product page

## Source

```astro
---
import { ChevronRight } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface Crumb {
  label: string;
  href?: string;
}

interface Props {
  /** Trail from the top level down. The last item is the current page and is not a link. */
  items: Crumb[];
  /** Accessible name of the nav landmark. */
  label?: string;
  class?: string;
}

const { items, label = "Breadcrumb", class: className } = Astro.props;
const last = items.length - 1;
---

<nav aria-label={label} class={className}>
  <ol role="list" class="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[0.8125rem]/5 text-muted-foreground">
    {
      items.map((item, i) => (
        <li class="inline-flex min-w-0 items-center gap-1.5">
          {i === last || !item.href ? (
            <span aria-current={i === last ? "page" : undefined} class={cn("max-w-40 truncate", i === last && "font-medium text-foreground")}>{item.label}</span>
          ) : (
            <a
              href={item.href}
              class="inline-flex min-h-6 max-w-40 items-center rounded-md px-1 -mx-1 text-muted-foreground transition-colors duration-150 ease-snappy hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
            ><span class="truncate">{item.label}</span></a>
          )}
          {i < last && <ChevronRight class="size-3.5 shrink-0 text-muted-foreground/70" aria-hidden="true" />}
        </li>
      ))
    }
  </ol>
</nav>
```
