Skip to content

Breadcrumb

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

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYes

Breadcrumb items to render; each one is placed in its own list item. Fragments are opened, so the items of a conditional group ({isAdmin && <>…</>}) each get their own list item too.

maxDisplayedItemsnumberNo

The most items the trail shows, the overflow button not counted. A longer trail collapses its middle items, from overflowIndex, into a "…" button that opens a menu of them (a link item becomes a Menu.ItemLink, an asChild element of a component (a router link) a Menu.ItemLink rendered by that component with the element's own props, its as included, a button item a Menu.Item). The first item and the last current item are never hidden. Without it the whole trail is shown. A value below 1 means 6, as in partitionBreadcrumbItems. Ignored with overflow="auto".

overflowIndexnumberNo1

The index of the first collapsed item (with maxDisplayedItems). It is at least 1, so the first item stays, and at most maxDisplayedItems - 1. Ignored with overflow="auto".

overflow'none' | 'auto'No'none'

'auto' fits the trail to its room: the middle items that do not fit are hidden, from the start of the trail; the first item and the last current item never are. A "…" list item with its own separator then stands just before the first hidden item (so the trail reads "Home › … › Parent › Page"), and its button (overflowLabel) opens a menu of the hidden items, in trail order. When even the first and the current item do not fit, the button covers the end of the trail. The room decides alone: maxDisplayedItems and overflowIndex do not apply. The trail list is then an Overflow (a role="list" element with the wave-overflow class and 4px of padding) that measures with ResizeObserver. 'none' shows the trail as the other props say.

overflowLabelstringNo"More items"

Accessible name of the overflow button (with maxDisplayedItems or overflow="auto").

size'small' | 'medium' | 'large'No'medium'

Text and divider size.

focusMode'tab' | 'arrow'No'tab'

'tab': every link is a Tab stop. 'arrow': the trail is one Tab stop (the last focused link or button, at first the first one) and the arrow keys (mirrored in right-to-left layouts), Home and End move between its links and the overflow button.

dividerSlot<'span'>No

The separator between items; a decorative <span>. null or undefined keep the chevron (mirrored in right-to-left layouts); false, or content that renders nothing, hides the separators. A custom divider is not mirrored.

refReact.Ref<HTMLElement>No

Ref to the <nav> element.

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 focusMode="arrow" keep their items and their one Tab stop), and no part hides what it holds. A part takes no children (the trail draws their content); the items take their own props and divider fills its own slot. In focusMode="arrow" a part's onKeyDown runs before the trail's arrow keys, which preventDefault() in it skips. Fluent UI's Breadcrumb has no such parts: its list is drawn inside its root, its items are yours.

Any other prop is passed to the element it renders (HTMLElement).

Parts

  • list
  • listItem
  • overflowButton
  • Breadcrumb.Item

Stable class names

PartClass
rootwave-breadcrumb
listwave-breadcrumb__list
listItemwave-breadcrumb__list-item
dividerwave-breadcrumb__divider
overflowButtonwave-breadcrumb__overflow-button