Breadcrumbs provide information about a user's current location within the application's page hierarchy.

Importing

The component can be imported via:

import { Breadcrumbs } from '@customerio/pluma-components/react';

Usage

The component requires an array of Breadcrumb objects to be passed in via the breadcrumbs prop. At a minimum, a Breadcrumb object should contain the following properties:

  • text
    • the text to display for the breadcrumb
  • href
    • optional - a URL to link to
  • onClick
    • optional - a click handler for the breadcrumb

See the API section for more details on the remaining available properties.

The component will render the provided breadcrumbs, separated by a / character. If href URLs are provided, the breadcrumbs will be rendered as links - except for the last item, which is assumed to be the current page and is rendered as plain text.

The component can be used as follows:

<Breadcrumbs
	breadcrumbs={[
		{ text: 'Page 1', href: '#' },
		{ text: 'Page 2', href: '#' },
		{ text: 'Page 3', onClick: (e) => { console.log('Page 3 clicked'); } },
		{ text: 'Page 4', href: '#' },
	]}
/>

Collapse behavior

When the breadcrumbs overflow their container, the component automatically collapses middle items into an ellipsis () dropdown menu. The first and last items are always visible, and the collapsed items can be accessed via the dropdown.

The collapse is recalculated on container resize, so the breadcrumbs will adapt to the available space.

Additionally, the maxItems prop can be used to set the maximum number of breadcrumbs to display before collapsing. The default value is 4. The max items count is respected even if the breadcrumbs would fit within the container without collapsing.

<Box style={{ width: 500, maxWidth: '100%', resize: 'horizontal', overflow: 'hidden' }}>
	<Breadcrumbs
		maxItems={6}
		breadcrumbs={[
			{ text: 'Home', href: '#' },
			{ text: 'Products', href: '#' },
			{ text: 'Category', href: '#' },
			{ text: 'Subcategory', href: '#' },
			{ text: 'Sub-subcategory', href: '#' },
			{ text: 'Item', href: '#' },
			{ text: 'Details', href: '#' },
			{ text: 'Detail item', href: '#' }
		]}
	/>
</Box>

API

An array of breadcrumbs to display.

Default:4

The maximum number of breadcrumbs to display before collapsing with an ellipsis. When collapsed, the ellipsis is included in the count of items.

Additional CSS classes to apply to the breadcrumb text content node.

The URL the breadcrumb should link to.

Whether the breadcrumb should render in a disabled state.

Whether the breadcrumb should be truncated with a max width. This is useful for breadcrumbs that may contain long text, like for dynamic model names.

Additional CSS classes to apply to the breadcrumb node.

Additional CSS classes to apply to the breadcrumb a node (if it exists).

Click handler for the breadcrumb item. If provided, it will be called when the breadcrumb is clicked.

The text content of the breadcrumb.

Collapsed breadcrumbs to display in this item's dropdown menu, when breadcrumbs are collapsed due to limited space.

On this page