# Breadcrumb

> A navigation landmark that shows where the current page sits in a hierarchy.

```tsx title="hero.tsx"
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'

export function BreadcrumbHeroDemo() {
  return (
    <Breadcrumb aria-label="Document path">
      <BreadcrumbList>
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/knowledge"
            onClick={(event) => event.preventDefault()}
          >
            Knowledge
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/knowledge/help-center"
            onClick={(event) => event.preventDefault()}
          >
            Help center
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbPage>Refunds.md</BreadcrumbPage>
        </BreadcrumbItem>
      </BreadcrumbList>
    </Breadcrumb>
  )
}
```

## Usage guidelines

- Use `Breadcrumb` to show the path from a top-level section to the current page, such as a document inside a knowledge base. Use `Tabs` to switch between sibling views and `Pagination` to move through a long list.
- Name the landmark with `aria-label` or `aria-labelledby`; the types require exactly one. Pass the consumer's localized text.
- End the trail with `BreadcrumbPage` for static current text. When the current item stays clickable, use `BreadcrumbLink` with `aria-current="page"` instead.
- Place a `BreadcrumbSeparator` between items. It renders a decorative `/` that assistive technology skips; pass children to swap the glyph.
- Route links through `BreadcrumbLink` with `render`, for example a router link. The rendered component must forward props and its ref to an anchor.
- The component does not infer routes, truncate or collapse. Constrain an item's width and truncate its text, or move ancestors into a `Menu`, at the call site.

## Anatomy

```tsx
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'
```

```tsx
<Breadcrumb>
  <BreadcrumbList>
    <BreadcrumbItem>
      <BreadcrumbLink />
    </BreadcrumbItem>
    <BreadcrumbSeparator />
    <BreadcrumbItem>
      <BreadcrumbPage />
    </BreadcrumbItem>
  </BreadcrumbList>
</Breadcrumb>
```

`BreadcrumbList` sets the row layout and typography; set a text class on it to restyle every item together.

## Examples

### Current page as a link

The last item keeps its link and marks itself with `aria-current="page"`, so it stays focusable and clickable — useful when clicking the current section resets filters or reloads the view.

```tsx title="current-link.tsx"
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'

export function BreadcrumbCurrentLinkDemo() {
  return (
    <Breadcrumb aria-label="App section path">
      <BreadcrumbList>
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/studio"
            onClick={(event) => event.preventDefault()}
          >
            Studio
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/studio/support-bot"
            onClick={(event) => event.preventDefault()}
          >
            Customer support bot
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/studio/support-bot/logs"
            aria-current="page"
            onClick={(event) => event.preventDefault()}
          >
            Logs
          </BreadcrumbLink>
        </BreadcrumbItem>
      </BreadcrumbList>
    </Breadcrumb>
  )
}
```

### Truncated label

Constrain an ancestor item with a max width, truncate the text inside its link, and pair it with a `Tooltip` so hover and keyboard focus reveal the full label. The link keeps its full accessible name and focus ring; keep the current page untruncated.

```tsx title="truncated-label.tsx"
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'

const fullLabel = 'Research and development documentation'

export function BreadcrumbTruncatedLabelDemo() {
  return (
    <Breadcrumb aria-label="Knowledge base path">
      <BreadcrumbList>
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/knowledge"
            onClick={(event) => event.preventDefault()}
          >
            Knowledge
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem className="max-w-32">
          <Tooltip>
            <TooltipTrigger
              render={
                <BreadcrumbLink
                  href="https://example.com/knowledge/research-and-development"
                  onClick={(event) => event.preventDefault()}
                />
              }
            >
              <span className="truncate">{fullLabel}</span>
            </TooltipTrigger>
            <TooltipContent>{fullLabel}</TooltipContent>
          </Tooltip>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbPage>Overview</BreadcrumbPage>
        </BreadcrumbItem>
      </BreadcrumbList>
    </Breadcrumb>
  )
}
```

### Collapsed ancestors

Collapse the middle of a deep path into a `Menu`, keeping the first item and the last two in place. The trigger carries its own accessible name, and each hidden ancestor stays a link through `MenuLinkItem`.

```tsx title="collapsed-ancestors.tsx"
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from '@langgenius/dify-ui/breadcrumb'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Menu, MenuContent, MenuLinkItem, MenuTrigger } from '@langgenius/dify-ui/menu'

const hiddenAncestors = [
  { label: 'Help center', href: 'https://example.com/knowledge/help-center' },
  { label: 'Billing', href: 'https://example.com/knowledge/help-center/billing' },
]

export function BreadcrumbCollapsedAncestorsDemo() {
  return (
    <Breadcrumb aria-label="Billing document path">
      <BreadcrumbList>
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/knowledge"
            onClick={(event) => event.preventDefault()}
          >
            Knowledge
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <Menu>
            <MenuTrigger
              render={
                <IconButton
                  aria-label="Show hidden pages"
                  className="active:bg-state-base-active data-popup-open:bg-state-base-hover data-popup-open:text-text-secondary"
                >
                  <span aria-hidden="true" className="i-ri-more-line size-4" />
                </IconButton>
              }
            />
            <MenuContent>
              {hiddenAncestors.map((ancestor) => (
                <MenuLinkItem
                  key={ancestor.href}
                  href={ancestor.href}
                  onClick={(event) => event.preventDefault()}
                >
                  {ancestor.label}
                </MenuLinkItem>
              ))}
            </MenuContent>
          </Menu>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbLink
            href="https://example.com/knowledge/help-center/billing/invoices"
            onClick={(event) => event.preventDefault()}
          >
            Invoices
          </BreadcrumbLink>
        </BreadcrumbItem>
        <BreadcrumbSeparator />
        <BreadcrumbItem>
          <BreadcrumbPage>Refunds.md</BreadcrumbPage>
        </BreadcrumbItem>
      </BreadcrumbList>
    </Breadcrumb>
  )
}
```

## API reference

### Breadcrumb

A navigation landmark displaying the current page's location within a hierarchy. Renders a `<nav>` element.

Requires `aria-label` or `aria-labelledby`. Consumers own separators, truncation, and overflow handling.

**Props**

| Prop               | Type     | Default | Description                                                                        |
| ------------------ | -------- | ------- | ---------------------------------------------------------------------------------- |
| `aria-label?`      | `string` | —       | Names the element for assistive technology. Pass either this or `aria-labelledby`. |
| `aria-labelledby?` | `string` | —       | Identifies the element that names this one. Pass either this or `aria-label`.      |

Valid prop combinations:

- `aria-label: string`, `aria-labelledby?: undefined`
- `aria-label?: undefined`, `aria-labelledby: string`

### BreadcrumbItem

Accepts the props of the element it renders.

### BreadcrumbLink

An interactive breadcrumb link supporting the `render` prop for custom link components. Renders an `<a>` element.

Inherits `render` from [Base UI null](https://base-ui.com/react/handbook/composition).

### BreadcrumbList

Accepts the props of the element it renders.

### BreadcrumbPage

Displays the non-interactive current page item with `aria-current="page"`. Renders a `<span>` element.

Accepts the props of the element it renders.

### BreadcrumbSeparator

**Props**

| Prop        | Type              | Default | Description            |
| ----------- | ----------------- | ------- | ---------------------- |
| `children?` | `React.ReactNode` | `'/'`   | The separator content. |
