# Breadcrumb

> Breadcrumb shows where a page sits in the site: a labelled nav with an ordered list of links that ends at the current page, marked with aria-current.

Source: https://vaneui.com/docs/basic-components/breadcrumb

Import: `import { Breadcrumb, BreadcrumbItem, Card, Col, PageTitle, ThemeProvider } from "@vaneui/ui"`

Breadcrumb shows where the current page sits in the site's hierarchy, as a trail of links from the top level down to the page itself. It renders a `<nav>` landmark labelled "Breadcrumb" around an ordered list, one `<li>` per BreadcrumbItem, with a chevron between items that assistive technology skips. For the main navigation of a site or a section, use [NavLink](/docs/basic-components/navlink) in a sidebar or tab bar. Breadcrumb needs `@vaneui/ui` 1.8.0 or later.

## Basic usage

Each BreadcrumbItem with `href` renders a link. An item without `href` renders text. The last item is the current page: it gets `aria-current="page"` and the stronger text color.

```tsx demo
<Breadcrumb>
  <BreadcrumbItem href="#home">Home</BreadcrumbItem>
  <BreadcrumbItem href="#docs">Docs</BreadcrumbItem>
  <BreadcrumbItem href="#components">Components</BreadcrumbItem>
  <BreadcrumbItem>Breadcrumb</BreadcrumbItem>
</Breadcrumb>
```

`sm`, `secondary` and `outline` are defaults, so a bare Breadcrumb has 14px text in the secondary text color, one step below body text.

## Marking the current page

When the current page is not the last item, for example in a trail that ends with a tab or a filter, set `current` on that item. An item with `current={false}` opts out, so a trail can mark no item at all.

```tsx demo
<Col>
  <Breadcrumb>
    <BreadcrumbItem href="#settings">Settings</BreadcrumbItem>
    <BreadcrumbItem href="#billing" current>Billing</BreadcrumbItem>
    <BreadcrumbItem href="#invoices">Invoices</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb>
    <BreadcrumbItem href="#settings">Settings</BreadcrumbItem>
    <BreadcrumbItem href="#billing" current={false}>Billing</BreadcrumbItem>
  </Breadcrumb>
</Col>
```

## Separators

`separator` replaces the chevron with any node: a character, an icon or an element of your own. The separator is drawn before every item but the first, in the tertiary text color, and is hidden from assistive technology.

```tsx demo
<Col>
  <Breadcrumb separator="/">
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem href="#projects">Projects</BreadcrumbItem>
    <BreadcrumbItem>vaneui</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb separator="·">
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem href="#blog">Blog</BreadcrumbItem>
    <BreadcrumbItem>Release notes</BreadcrumbItem>
  </Breadcrumb>
</Col>
```

## Sizes

The size prop on Breadcrumb sets the text, the separator and the gap between items for the whole trail.

```tsx demo
<Col>
  <Breadcrumb xs>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>xs</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>sm</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb md>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>md</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb lg>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>lg</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb xl>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>xl</BreadcrumbItem>
  </Breadcrumb>
</Col>
```

## Appearances

An appearance on Breadcrumb colors the links and the current page. The default `secondary` keeps the trail quieter than the page title under it.

```tsx demo
<Col>
  <Breadcrumb primary>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>Primary</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb accent>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>Accent</BreadcrumbItem>
  </Breadcrumb>
  <Breadcrumb info>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>Info</BreadcrumbItem>
  </Breadcrumb>
</Col>
```

## Long trails on narrow screens

The list wraps, and each item keeps its text on one line, so a long trail breaks between items rather than inside one. The separator stays with the item that follows it.

```tsx demo
<Card className="max-w-xs">
  <Breadcrumb>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem href="#docs">Documentation</BreadcrumbItem>
    <BreadcrumbItem href="#components">Form components</BreadcrumbItem>
    <BreadcrumbItem>Field sections</BreadcrumbItem>
  </Breadcrumb>
</Card>
```

## A page header with a breadcrumb

Put the Breadcrumb above the page title, so the trail reads first and the title names the last item.

```tsx demo
<Col>
  <Breadcrumb>
    <BreadcrumbItem href="#projects">Projects</BreadcrumbItem>
    <BreadcrumbItem href="#website">Website</BreadcrumbItem>
    <BreadcrumbItem>Settings</BreadcrumbItem>
  </Breadcrumb>
  <PageTitle>Settings</PageTitle>
</Col>
```

## Next.js Link integration

Pass the router's link component through `tag`, like on [Button](/docs/basic-components/button) and [NavLink](/docs/basic-components/navlink). The item keeps its styles and `aria-current`, and the router handles the click:

```tsx
import Link from "next/link";

<Breadcrumb>
  <BreadcrumbItem tag={Link} href="/">Home</BreadcrumbItem>
  <BreadcrumbItem tag={Link} href="/docs">Docs</BreadcrumbItem>
  <BreadcrumbItem>Button</BreadcrumbItem>
</Breadcrumb>
```

## Customizing

Breadcrumb has four theme nodes: `breadcrumb.main` (the `<nav>`), `breadcrumb.list` (the `<ol>`), `breadcrumb.item` (each link or text) and `breadcrumb.separator`.

```tsx demo
<ThemeProvider themeDefaults={{
  breadcrumb: { main: { md: true }, item: { fontMedium: true } },
}}>
  <Breadcrumb>
    <BreadcrumbItem href="#home">Home</BreadcrumbItem>
    <BreadcrumbItem>Customized</BreadcrumbItem>
  </Breadcrumb>
</ThemeProvider>
```

## Frequently asked questions

### Should the last item be a link?

No. The last item is the page you are on, so a link to it goes nowhere. Leave out its `href`, and it renders as text with `aria-current="page"`. Give it an `href` only when the item stands for a parent view, such as a list the current page was opened from.

### How do I translate the "Breadcrumb" label?

Pass `aria-label` on Breadcrumb, for example `aria-label="Fil d'Ariane"`. It replaces the default label of the `<nav>` landmark, which screen reader users hear when they move between landmarks.

### Can a page have more than one Breadcrumb?

It can, but each `<nav>` landmark then needs a label of its own, such as "Breadcrumb" and "Related sections", so screen reader users can tell them apart. Most pages need one trail, at the top of the main content.

## Props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `primary` | Appearance |  | Primary color appearance (gray) |
| `accent` | Appearance |  | Accent color appearance (rose) |
| `secondary` | Appearance | yes | Secondary color appearance (gray) |
| `tertiary` | Appearance |  | Tertiary color appearance |
| `success` | Appearance |  | Success color appearance (green) |
| `danger` | Appearance |  | Danger color appearance (red) |
| `warning` | Appearance |  | Warning color appearance (amber) |
| `info` | Appearance |  | Info color appearance (cyan) |
| `inheritAppearance` | Appearance |  | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `fontSans` | Font Family | yes | Sans-serif font family (default) — emits font-sans |
| `fontSerif` | Font Family |  | Serif font family — emits font-serif |
| `fontMono` | Font Family |  | Monospace font family — emits font-mono |
| `fontHeading` | Font Family |  | Heading font family (defaults to sans, customizable via --font-heading) — emits font-heading |
| `fontThin` | Font Weight |  | Thin font weight (100) — emits font-thin |
| `fontExtralight` | Font Weight |  | Extra light font weight (200) — emits font-extralight |
| `fontLight` | Font Weight |  | Light font weight (300) — emits font-light |
| `fontNormal` | Font Weight |  | Normal font weight (400) — emits font-normal |
| `fontMedium` | Font Weight |  | Medium font weight (500) — emits font-medium |
| `fontSemibold` | Font Weight |  | Semibold font weight (600) — emits font-semibold |
| `fontBold` | Font Weight |  | Bold font weight (700) — emits font-bold |
| `fontExtrabold` | Font Weight |  | Extra bold font weight (800) — emits font-extrabold |
| `fontBlack` | Font Weight |  | Black font weight (900) — emits font-black |
| `margin` | Margin |  | Enable margin on all sides |
| `marginX` | Margin |  | Enable only horizontal (inline) margin |
| `marginY` | Margin |  | Enable only vertical (block) margin |
| `marginT` | Margin |  | Enable only top margin |
| `marginB` | Margin |  | Enable only bottom margin |
| `noMargin` | Margin |  | Disable margin (reset to 0) |
| `xs` | Size |  | Extra small size |
| `sm` | Size | yes | Small size |
| `md` | Size |  | Medium size (default) |
| `lg` | Size |  | Large size |
| `xl` | Size |  | Extra large size |
| `skeleton` | Skeleton |  | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too |
| `filled` | Variant |  | Filled variant - solid background with contrasting text color |
| `outline` | Variant | yes | Outline variant - transparent background with border and colored text (default) |
| `ghost` | Variant |  | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background |

Layout and utility props (Display, Hide, Items, Justify, Overflow, Position, Show) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).

## BreadcrumbItem props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `fontThin` | Font Weight |  | Thin font weight (100) — emits font-thin |
| `fontExtralight` | Font Weight |  | Extra light font weight (200) — emits font-extralight |
| `fontLight` | Font Weight |  | Light font weight (300) — emits font-light |
| `fontNormal` | Font Weight |  | Normal font weight (400) — emits font-normal |
| `fontMedium` | Font Weight |  | Medium font weight (500) — emits font-medium |
| `fontSemibold` | Font Weight |  | Semibold font weight (600) — emits font-semibold |
| `fontBold` | Font Weight |  | Bold font weight (700) — emits font-bold |
| `fontExtrabold` | Font Weight |  | Extra bold font weight (800) — emits font-extrabold |
| `fontBlack` | Font Weight |  | Black font weight (900) — emits font-black |

Layout and utility props (Cursor, Focus Visible, Transition, Whitespace) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
