Breadcrumbs
A trail of links that shows where a page sits, and takes people back up a level in one click.
import { Breadcrumbs, BreadcrumbItem } from '@halo-ds/react';
When to use it
Use breadcrumbs on pages that sit two or more levels deep, like settings, files or product categories. Each level is a link except the last, which is the page you are on. On long paths the middle levels collapse into a "…" button so the trail stays on one line.
Do
- Place breadcrumbs at the top of the page, above the title.
- Match each label to the title of the page it links to.
- End with the current page, as plain text.
- Collapse the middle levels when the trail gets long.
Don't
- Use breadcrumbs for steps in a process; use a Stepper instead.
- Show them on top-level pages with nothing above.
- Mix slash and caret separators in one product.
- Let the trail wrap onto two lines.
Props
Breadcrumbs props
| Prop | Type | What it does | |
|---|---|---|---|
size | `BreadcrumbsSize \ | undefined` | 12px (sm) or 14px (md) text. Figma: Size. |
separator | `BreadcrumbsSeparator \ | undefined` | The mark between levels. Figma: Separator. |
maxItems | `number \ | undefined` | When there are more levels than this, the middle ones collapse into "…". Figma: Levels=Collapsed. |
children (required) | ReactNode | BreadcrumbItem elements, from the top level down to the current page. | |
classNames | `Partial<Record<BreadcrumbsPart, string>> \ | undefined` | Extra class names for the parts inside the component, by part name, like { header: 'my-header' }. |
styles | `Partial<Record<BreadcrumbsPart, CSSProperties>> \ | undefined` | Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }. |
It also takes the usual HTML attributes for its element.
BreadcrumbItem props
| Prop | Type | What it does | |
|---|---|---|---|
href | `string \ | undefined` | Where the link goes. Leave it off the last item, which is the current page. |
icon | ReactNode | An icon before the label, often a house on the first item. Figma: Show icon and Icon. | |
children (required) | ReactNode | The name of the page. Figma: Label. |
It also takes the usual HTML attributes for its element.
Examples
Overview
import { BreadcrumbItem, Breadcrumbs } from '@halo-ds/react';
import { House } from '@phosphor-icons/react';
export default function Example() {
return (
<Breadcrumbs>
<BreadcrumbItem href="#" icon={<House />}>Home</BreadcrumbItem>
<BreadcrumbItem href="#">Projects</BreadcrumbItem>
<BreadcrumbItem>Brand refresh</BreadcrumbItem>
</Breadcrumbs>
);
}
Sizes and separators
Small for dense layouts, medium for most pages. Slash or caret: pick one and use it everywhere.
import { BreadcrumbItem, Breadcrumbs } from '@halo-ds/react';
import { House } from '@phosphor-icons/react';
export default function Demo() {
return (
<div className="demo-stack">
<Breadcrumbs size="sm">
<BreadcrumbItem href="#" icon={<House />}>Home</BreadcrumbItem>
<BreadcrumbItem href="#">Projects</BreadcrumbItem>
<BreadcrumbItem>Settings</BreadcrumbItem>
</Breadcrumbs>
<Breadcrumbs separator="caret">
<BreadcrumbItem href="#" icon={<House />}>Home</BreadcrumbItem>
<BreadcrumbItem href="#">Projects</BreadcrumbItem>
<BreadcrumbItem>Settings</BreadcrumbItem>
</Breadcrumbs>
</div>
);
}
Long paths
With maxItems, the middle collapses into a "..." people can open.
import { BreadcrumbItem, Breadcrumbs } from '@halo-ds/react';
import { House } from '@phosphor-icons/react';
export default function Demo() {
return (
<Breadcrumbs separator="caret" maxItems={4}>
<BreadcrumbItem href="#" icon={<House />}>Home</BreadcrumbItem>
<BreadcrumbItem href="#">Workspace</BreadcrumbItem>
<BreadcrumbItem href="#">Projects</BreadcrumbItem>
<BreadcrumbItem href="#">Design</BreadcrumbItem>
<BreadcrumbItem href="#">Mobile app</BreadcrumbItem>
<BreadcrumbItem>Screens</BreadcrumbItem>
</Breadcrumbs>
);
}
More: https://halodesignsystem.dev/components/breadcrumbs