Breadcrumb
Displays the path to the current resource using a hierarchy of links.
Breadcrumb shows the hierarchical path to the current page, at the top of the content. Every segment is clickable except the last one (rendered as BreadcrumbPage). Use BreadcrumbEllipsis to collapse a path that is too long, optionally combined with DropdownMenu to reveal the hidden segments.
Installation
$ bext ui add breadcrumb
Copy and paste the following into src/components/ui/breadcrumb.tsx.
Usage
Anatomy
<Breadcrumb>
└── <BreadcrumbList>
├── <BreadcrumbItem>
│ └── <BreadcrumbLink href="/">Home</BreadcrumbLink>
├── <BreadcrumbSeparator />
├── <BreadcrumbItem>
│ └── <BreadcrumbLink href="/docs">Docs</BreadcrumbLink>
├── <BreadcrumbSeparator />
└── <BreadcrumbItem>
└── <BreadcrumbPage>Components</BreadcrumbPage>API Reference
Breadcrumb
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | A BreadcrumbList. Rendered inside a <nav>. |
| ariaLabel | string | "breadcrumb" | aria-label of the <nav>. |
| items | { label: string; href?: string }[] | — | Shorthand: generates the list, with chevron separators and the last entry as the current page. |
| className | string | — | Extra classes on the <nav>. |
BreadcrumbList
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Extra classes on the <ol>. |
| children | ReactNode | — | Rendered as <ol>. Default: flex flex-wrap items-center gap-1.5 text-sm text-muted-foreground. |
BreadcrumbItem
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Extra classes on the <li>. |
| children | ReactNode | — | Rendered as <li>. Default: inline-flex items-center gap-1.5. |
BreadcrumbLink
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | "#" | Target of the segment link. |
| className | string | — | Extra classes on the <a>. |
| children | ReactNode | — | Clickable segment. hover:text-foreground. |
BreadcrumbPage
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Extra classes on the . |
| children | ReactNode | — | Current segment (not clickable). Rendered as . |
BreadcrumbSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Extra classes on the <li>, which is role="presentation" and aria-hidden. |
| children | ReactNode | — | Default: chevron-right. Can be replaced with a dot, a slash or another icon. |
BreadcrumbEllipsis
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Renders a more-horizontal icon + an sr-only "More". Wrap it with DropdownMenu to reveal the hidden segments. |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus through each BreadcrumbLink in order. |
| Enter | Follows the focused link. |
Accessibility
The root <nav> has aria-label="breadcrumb", announced by assistive technologies as "breadcrumb navigation". When a page shows more than one breadcrumb, give each a distinct name with ariaLabel so the landmarks can be told apart (the demos on this page do). The list is an ordered <ol> (order = hierarchy). The current segment has aria-current="page". Separators have aria-hidden="true" so assistive technologies do not read them.
Examples
Basic
Custom separator
Slash separator
<BreadcrumbSeparator>/</BreadcrumbSeparator>
Collapsed (ellipsis)
Dropdown (composed)
RTL (Arabic)
Edit this example live in the bext playground. It compiles and runs entirely in your browser.
On This Page