Breadcrumb
A breadcrumb trail: a <nav aria-label="Breadcrumb"> landmark with an ordered list. Each child is placed in its own list item (Fragments are opened, so each of their items gets one too); from the second one on, the item begins with a decorative separator chevron that is mirrored in right-to-left layouts (divider replaces or hides it).
maxDisplayedItems collapses the middle of a long trail into a "…" menu button, and overflow="auto" collapses it to the room it has instead (a "…" menu button stands in for the hidden middle items); size sets the text step and focusMode="arrow" makes the trail one Tab stop with arrow-key navigation.
Breadcrumb.Item is also exported as BreadcrumbItem: React Server Components import the flat name, because dotted access needs a client file.
Examples
Default
export const Default: Story = {};With Icons
export const WithIcons: Story = {
args: {
children: [
<Breadcrumb.Item key="home" href="#" icon={{ children: '🏠' }}>
Home
</Breadcrumb.Item>,
<Breadcrumb.Item key="documents" href="#" icon={{ children: '📁' }}>
Documents
</Breadcrumb.Item>,
<Breadcrumb.Item key="report" current icon={{ children: '📄' }}>
Report.pdf
</Breadcrumb.Item>,
],
},
};Current Item
export const CurrentItem: Story = {
args: {
children: [
<Breadcrumb.Item key="dashboard" href="#">
Dashboard
</Breadcrumb.Item>,
<Breadcrumb.Item key="settings" href="#">
Settings
</Breadcrumb.Item>,
<Breadcrumb.Item key="account" href="#">
Account
</Breadcrumb.Item>,
<Breadcrumb.Item key="profile" current>
Profile
</Breadcrumb.Item>,
],
},
};With Buttons
export const WithButtons: Story = {
args: {
children: [
<Breadcrumb.Item key="home" onClick={fn()}>
Home
</Breadcrumb.Item>,
<Breadcrumb.Item key="library" onClick={fn()}>
Library
</Breadcrumb.Item>,
<Breadcrumb.Item key="album" current>
Album
</Breadcrumb.Item>,
],
},
};Collapsed Trail
export const CollapsedTrail: Story = {
args: {
maxDisplayedItems: 4,
children: trail(),
},
};Collapse From Index
export const CollapseFromIndex: Story = {
args: {
maxDisplayedItems: 5,
overflowIndex: 2,
overflowLabel: 'Hidden levels',
children: trail(),
},
};Responsive Trail
export const ResponsiveTrail: Story = {
args: {
overflow: 'auto',
children: trail(),
},
render: (args) => (
<div className="w-[360px] max-w-full min-w-40 resize-x overflow-hidden rounded border border-wave-border">
<Breadcrumb {...args} />
</div>
),
};Sizes
export const Sizes: Story = {
render: (args) => (
<div className="flex flex-col gap-4">
{(['small', 'medium', 'large'] as const).map((size) => (
<Breadcrumb key={size} {...args} size={size} aria-label={`Breadcrumb, ${size}`}>
{trail(TRAIL.slice(0, 4))}
</Breadcrumb>
))}
</div>
),
};Arrow Key Focus
export const ArrowKeyFocus: Story = {
args: {
focusMode: 'arrow',
maxDisplayedItems: 4,
children: trail(),
},
};Custom Divider
export const CustomDivider: Story = {
render: (args) => (
<div className="flex flex-col gap-4">
<Breadcrumb {...args} aria-label="Breadcrumb, slash divider" divider="/">
{trail(TRAIL.slice(0, 4))}
</Breadcrumb>
<Breadcrumb {...args} aria-label="Breadcrumb, no divider" divider={false}>
{trail(TRAIL.slice(0, 4))}
</Breadcrumb>
</div>
),
};Truncated Names With Tooltip
export const TruncatedNamesWithTooltip: Story = {
render: (args) => {
const truncated = isTruncatableBreadcrumbContent(LONG_NAME, 30);
const link = (
<Breadcrumb.Item href="#">{truncateBreadcrumbLongName(LONG_NAME)}</Breadcrumb.Item>
);
return (
<Breadcrumb {...args}>
<Breadcrumb.Item href="#">Home</Breadcrumb.Item>
{truncated ? (
<Tooltip content={truncateBreadcrumbLongTooltip(LONG_NAME)}>{link}</Tooltip>
) : (
link
)}
<Breadcrumb.Item current>Summary</Breadcrumb.Item>
</Breadcrumb>
);
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
children | React.ReactNode | Yes | Breadcrumb items to render; each one is placed in its own list item. Fragments are opened, so the items of a conditional group ( | |
maxDisplayedItems | number | No | The most items the trail shows, the overflow button not counted. A longer trail collapses its middle items, from | |
overflowIndex | number | No | 1 | The index of the first collapsed item (with |
overflow | 'none' | 'auto' | No | 'none' |
|
overflowLabel | string | No | "More items" | Accessible name of the overflow button (with |
size | 'small' | 'medium' | 'large' | No | 'medium' | Text and divider size. |
focusMode | 'tab' | 'arrow' | No | 'tab' |
|
divider | Slot<'span'> | No | The separator between items; a decorative | |
ref | React.Ref<HTMLElement> | No | Ref to the | |
slotProps | { list?: SlotPartWithRef<'ol', HTMLElement>; listItem?: SlotPart<'li'>; overflowButton?: SlotPart<'button'> } | No | Props for the elements the trail draws around its items, by part, merged into each part's own: your classes after the part's (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref attached. Every attribute the trail sets on a part is locked, no part takes another role, a tab index or a roving container's marker (the arrow keys of |
Any other prop is passed to the element it renders (HTMLElement).
Parts
listlistItemoverflowButtonBreadcrumb.Item
Stable class names
| Part | Class |
|---|---|
root | wave-breadcrumb |
list | wave-breadcrumb__list |
listItem | wave-breadcrumb__list-item |
divider | wave-breadcrumb__divider |
overflowButton | wave-breadcrumb__overflow-button |