# Breadcrumbs

Shows where a page sits in a hierarchy, collapsing middle levels into a menu when long.

- Family: navigation
- Import: `import { Breadcrumbs, Breadcrumb } from "@senvenli/react/navigation";`
- Page: https://design.senvenli.com/docs/components/breadcrumbs
- JSON: https://design.senvenli.com/docs/components/breadcrumbs.json

## Example: Where the page sits

From the section root to the current page, which is not a link.

```tsx
import { Breadcrumbs } from "@senvenli/react/navigation";

export default function Example() {
  return <Breadcrumbs aria-label="Location" items={[{ label: "Projects", href: "#" }, { label: "Atlas", href: "#" }, { label: "Settings" }]} />;
}
```

## Examples

### A long trail

With more than four levels, the middle ones fold into a menu.

```tsx
import { Breadcrumbs } from "@senvenli/react/navigation";

export default function Example() {
  return (
    <Breadcrumbs
      aria-label="Location"
      items={[
        { label: "Customers", href: "#" },
        { label: "Analytical Engines Ltd", href: "#" },
        { label: "Orders", href: "#" },
        { label: "ORD-1040", href: "#" },
        { label: "Invoices", href: "#" },
        { label: "INV-2041" },
      ]}
    />
  );
}
```

### Composed from parts

`Breadcrumb` children with icons; the last one is the current page.

```tsx
import { Breadcrumb, Breadcrumbs } from "@senvenli/react/navigation";

export default function Example() {
  return (
    <Breadcrumbs>
      <Breadcrumb href="#" icon="folder">
        Projects
      </Breadcrumb>
      <Breadcrumb href="#" icon="folder">
        Website redesign
      </Breadcrumb>
      <Breadcrumb icon="file-text">Launch plan</Breadcrumb>
    </Breadcrumbs>
  );
}
```

## Guidelines

### When to use it

- Pages nested two or more levels deep.

### Use something else when

- [link](https://design.senvenli.com/docs/components/link.md): One way back to the parent page is enough.
- [stepper](https://design.senvenli.com/docs/components/stepper.md): The levels are steps of a flow.

## Accessibility

Built in:

- A navigation landmark; the current page has aria-current.

You provide:

- With children: a textValue on a Breadcrumb whose label is not plain text, for the folded menu.

## API reference

### Breadcrumbs

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| items | `readonly BreadcrumbItem[]` |  | no | From the section root ("Projects"), never "Home", to the current page. Leave it out to compose `Breadcrumb`s as children instead. |
| children | `React.ReactNode` |  | no | With no `items`: `Breadcrumb`s from the root to the current page (the last one). |
| aria-label | `string` |  | no | Names the navigation landmark; "Location" by default. |

### Breadcrumb

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| href | `string` |  | no | A page; leave it out on the last one, the current page. |
| icon | `IconName` |  | no |  |
| children | `React.ReactNode` |  | yes | The level's name. It may hold more than text; then give `textValue` for the folded "…" menu. |
| textValue | `string` |  | no | The words for the "…" menu when this level folds; the label itself when it is plain text. |

### Tokens it reads

`--ds-border-focused`, `--ds-icon-subtle`, `--ds-radius-small`, `--ds-space-050`, `--ds-text`, `--ds-text-subtle`

## Related

- [sidebar](https://design.senvenli.com/docs/components/sidebar.md)
