---
title: Breadcrumb
description: Show a resource hierarchy and mark its current page.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# Breadcrumb

> Show a resource hierarchy and mark its current page.

## Anatomy

```text
Breadcrumb [component; slot=root; <nav>]
└── list [slot]
    ├── item [slot]
    │   ├── link [slot]
    │   │   ├── leading [slot]
    │   │   └── label [slot]
    │   └── page [slot]
    │       ├── leading [slot]
    │       └── label [slot]
    └── separator [slot]
```

## Usage

Use Breadcrumb to show where a resource sits in a navigation hierarchy. Keep ancestor destinations
as links and render the current page as a non-link item. For in-page section switching, use
[Tabs](https://moraine.subf.dev/components/tabs.md) instead.

```tsx
import { Breadcrumb } from 'moraine'

export function Example() {
  return <Breadcrumb items={[{ label: 'Home', href: '/' }, { label: 'Settings' }]} />
}
```

### Items and current page

Use `href` for navigable ancestors, with `target`, `rel`, and `onClick` as needed. The last item is
the current page by default; set `active` on another item to mark it instead (the first `active` item
wins). The current page renders as a `span` with `aria-current="page"`. Disabled ancestors render
without `href` or `onClick` and expose `aria-disabled="true"`. `disabled` has no effect on the
current page.

```tsx
<Breadcrumb
  items={[
    { label: 'Home', href: '/' },
    { label: 'Components', href: '/button' },
    { label: 'Breadcrumb' },
  ]}
/>
```

```tsx
<Breadcrumb
  items={[
    { label: 'Home', href: '/', icon: 'i-lucide:home' },
    { label: 'Private workspace', href: '/workspace', disabled: true },
    { label: 'Activity', active: true },
    { label: 'Archived' },
  ]}
/>
```

`separator` accepts an icon name, an element, or a component, and defaults to `icon-chevron-right`.
It is hidden from assistive technology. `wrap` (default `true`) lets a long trail break onto extra
lines in a narrow column; with `wrap={false}`, the trail stays on one line and clips any overflow.
The `<nav>` is labeled `breadcrumb` by default. Set `aria-label`, or `translations={{ label }}`, to
change it.

Pass `itemRender` to replace each item's link or page element, for example with a router link. The
component receives `{ item, index, active, disabled }` and is responsible for `aria-current` and
disabled handling.

```tsx
<Breadcrumb
  items={items}
  itemRender={(ctx) => (
    <A href={ctx.item.href ?? '#'} aria-current={ctx.active ? 'page' : undefined}>
      {ctx.item.label}
    </A>
  )}
/>
```

## Examples

### Trail to the current page

Link ancestors and leave the last item as the current page.

```tsx
import { Breadcrumb } from 'moraine'
import type { BreadcrumbT } from 'moraine'

const BREADCRUMB_ITEMS = [
  { label: 'Home', href: '/' },
  { label: 'Components', href: '/button' },
  { label: 'Breadcrumb' },
] satisfies BreadcrumbT.Item[]

export function ItemsPage() {
  return (
    <div class="max-w-md w-full">
      <Breadcrumb items={BREADCRUMB_ITEMS} />
    </div>
  )
}
```

### Locked ancestor with a custom separator

Keep a disabled private workspace in the trail. Replace the chevron with a slash.

```tsx
import { Breadcrumb } from 'moraine'

export function CustomSeparatorDisabled() {
  return (
    <Breadcrumb
      separator={() => <span>/</span>}
      classes={{
        separator: 'size-unset',
      }}
      items={[
        { label: 'Home', href: '/', icon: 'i-lucide:home' },
        { label: 'Private workspace', href: '/breadcrumb', disabled: true, icon: 'i-lucide:lock' },
        { label: 'Activity' },
      ]}
    />
  )
}
```

### Long trail in a narrow column

Leave `wrap` on so the trail can break across lines. Set `wrap={false}` to keep every item on one line.

```tsx
import { Breadcrumb, Switch } from 'moraine'
import { createSignal } from 'solid-js'

export function Wrapping() {
  const [wrap, setWrap] = createSignal(true)

  return (
    <div class="min-w-0 w-full space-y-4">
      <Switch checked={wrap()} onCheckedChange={setWrap} label="Wrap items" />

      <div
        class="p-4 border border-border rounded-lg"
        classList={{ 'w-full max-w-sm': wrap(), 'w-max': !wrap() }}
      >
        <Breadcrumb
          wrap={wrap()}
          classes={{
            list: wrap() ? undefined : 'overflow-visible',
            item: wrap() ? undefined : 'shrink-0',
          }}
          items={[
            { label: 'Home', href: '#' },
            { label: 'Workspace', href: '#' },
            { label: 'Projects', href: '#' },
            { label: 'Design system', href: '#' },
            { label: 'Components', href: '#' },
            { label: 'Breadcrumb' },
          ]}
        />
      </div>

      <p class="text-sm text-muted-foreground">
        Turn wrapping off to show the full trail on a single line.
      </p>
    </div>
  )
}
```

### Custom item rendering

Use `itemRender` to render each item yourself for router links or custom chip styling. It receives
`item`, `index`, `active`, and `disabled`.

```tsx
import { Breadcrumb } from 'moraine'
import type { BreadcrumbT } from 'moraine'

const TRAIL = [
  { label: 'Documentation', href: '/docs' },
  { label: 'Components', href: '/components' },
  { label: 'Breadcrumb' },
] satisfies BreadcrumbT.Item[]

export function CustomItemRender() {
  return (
    <div class="max-w-md w-full">
      <Breadcrumb
        items={TRAIL}
        itemRender={(props) => (
          <a
            href={props.item.href}
            class="text-xs px-2 py-1 rounded-md inline-flex gap-1.5 transition-colors items-center"
            classList={{
              'bg-primary/10 text-primary font-medium': props.active,
              'text-muted-foreground hover:text-foreground': !props.active,
            }}
          >
            <span>{props.item.label}</span>
          </a>
        )}
      />
    </div>
  )
}
```

## API Reference

### Attributes

| Attributes | Slot | Description |
| --- | --- | --- |
| `data-disabled` | `breadcrumb-link` | Present when the component, slot, or item is disabled. |
| `data-current` | `breadcrumb-page` | Present when the item represents the current location or step. |

### Props

Props for the Breadcrumb component.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| itemRender | Component<ItemRenderProps> \| undefined | — | Component rendered for every item, replacing its default link or page element (the `<li>` and<br>separator are kept). Use it to integrate a router link. Receives `{ item, index, active,<br>disabled }`; you are responsible for `aria-current` and disabled handling. |
| items | ({<br>  /** Text or content of the item. Nothing is rendered for an empty label. */<br>  label?: JSX.Element;<br>  /** Name of an icon rendered before the label. */<br>  icon?: IconT.Name;<br>  /** Link destination. Applied only to an interactive item: the current page and disabled items<br>render without `href`, `target`, `rel` and `onClick`. */<br>  href?: string;<br>  /** Browsing context for the link, such as `'_blank'`. Ignored for the current page and disabled items. */<br>  target?: string;<br>  /** Link relationship, such as `'noopener'`. Ignored for the current page and disabled items. */<br>  rel?: string;<br>  /** Marks this item as the current page, rendered as a non-link with `aria-current="page"`. When<br>no item sets it, the last item is the current page. The first item with `active` wins. */<br>  active?: boolean;<br>  /** Whether the item is disabled: it renders as a non-interactive element with<br>`aria-disabled="true"` and without `href` or `onClick`. Has no effect on the current page. */<br>  disabled?: boolean;<br>  /** Click handler for the item's link. Not attached to the current page or disabled items. */<br>  onClick?: JSX.EventHandlerUnion<HTMLAnchorElement, MouseEvent>;<br>})[] \| undefined | — | Items of the trail, from the root to the current page. Separators are rendered between<br>consecutive items automatically. |
| ref | Ref<HTMLElement> \| undefined | — | Ref forwarded to the root `<nav>` element. |
| separator | IconT.Name \| undefined | 'icon-chevron-right' | Name of the icon rendered between consecutive items. The separator is hidden from assistive<br>technology. |
| size | 'sm' \| 'md' \| 'lg' \| undefined | 'md' | Visual size of the component. |
| translations | Translations \| undefined | — | Overrides the built-in strings for this instance. The only key is `label`, the default<br>`aria-label` of the `<nav>` (default `'breadcrumb'`). An explicit `aria-label` prop wins. |
| wrap | boolean \| undefined | true | Visual wrap of the component. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| classes | Classes \| undefined | — | Family slot class defaults for this instance. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |
| styles | Styles \| undefined | — | Family slot style defaults for this instance. |

**`itemRender` example**

```tsx
import { Breadcrumb } from 'moraine'

<Breadcrumb
  items={[{ label: 'Home', href: '/' }, { label: 'Settings' }]}
  itemRender={(ctx) => (
    <a href={ctx.item.href} aria-current={ctx.active ? 'page' : undefined}>
      {ctx.item.label}
    </a>
  )}
/>
```

**`items` example**

```tsx
import { Breadcrumb } from 'moraine'

<Breadcrumb
  items={[
    { label: 'Home', href: '/' },
    { label: 'Docs', href: '/docs', target: '_blank', rel: 'noopener' },
    { label: 'Archive', disabled: true },
    { label: 'Current page' },
  ]}
/>
```
