Web component implementation of a Spectrum design Breadcrumbs
npm install @spectrum-web-components/breadcrumbsAn shows hierarchy and navigational context for a user's location within an app. The component defines its list of items using child elements placed in its default slot.
View the design documentation for this component.


``zsh`
yarn add @spectrum-web-components/breadcrumbs
Import the side effectful registration of and via:
`js`
import '@spectrum-web-components/breadcrumbs/sp-breadcrumbs.js';
import '@spectrum-web-components/breadcrumbs/sp-breadcrumb-item.js';
When looking to leverage the Breadcrumbs or BreadcrumbItem base class as a type and/or for extension purposes, do so via:
`js`
import {
Breadcrumbs,
BreadcrumbItem,
} from '@spectrum-web-components/breadcrumbs';
Breadcrumbs consist of several key parts:
- A breadcrumbs list, usually consisting of multiple breadcrumb items, with a separator between each item.
- A breadcrumbs title at the end of the list displaying the current location within the hierarchy.
- A truncation menu may also appear, which displays all options within a breadcrumb. Within the menu, items are listed with the hierarchy ordered from the top (root) to the bottom, and will include the currently selected item. Breadcrumbs truncate when there isn't enough space to show all items, or when the list contains five or more levels. Truncation helps manage space and keep the most relevant breadcrumbs visible in deeply nested hierarchies.
`html`
#### Compact
When needing to optimize for functional space of , the compact property can be used to reduce the height of the breadcrumbs while still maintaining the proper user context.
`html`
#### Overflowing
When space becomes limited or the maximum visible items are reached, the component automatically moves the first breadcrumbs into an action menu, adjusting dynamically as the window is resized.
By default, the maximum number of visible breadcrumbs is 4, as recommended by Spectrum Design. You can override this by using the max-visible-items attribute. The component will always display the action menu and the breadcrumbs title, so the minimum number of visible items is 1.
`html`
`html`
`html`
These breadcrumbs are in a resizable container. Reduce the size of the container to see how the maximum number of visible items changes.
`html`
#### Show root
Use the root slot on the first breadcrumb item to always render the first breadcrumb item, even if the breadcrumbs are overflowing. The root will always show in addition to the number of items specified with max-visible-items.
`html`
Your stuff
`html`
Your stuff
#### Links
By default, sp-breadcrumbs emits a change event when clicking on one of its children.href
However, there may be cases in which clicking should redirect to another page. This can be achieved by using the attribute instead of value.change
Please note that the event will no longer be triggered in this case.
`html`
Home
Trend
March 2019 Assets
#### Custom Action Menu
The component offers the possibility to replace the action menu's icon with a custom one using the icon slot. Moreover, for accessibility purposes you can provide an internationalized string for the menu label using the menu-label attribute.
`html
`
The component provides the following accessibility features:
- Automatically sets role="navigation" to ensure proper semantic meaning for assistive technologies
- Uses semantic markup by rendering a
with each assigned role="listitem"
- The last breadcrumb item automatically receives aria-current="page" to indicate the current location
- Sets aria-label based on the label property, defaulting to "Breadcrumbs" if none is provided
- Each breadcrumb item is keyboard accessible with tabindex="0"
- Provides an accessible action menu with keyboard navigation and screen reader support#### Best practices
- Limit breadcrumb depth: Keep breadcrumbs to 4-5 levels maximum to avoid overwhelming users
- Use descriptive labels: Each breadcrumb item should clearly identify the section or page
- Maintain consistent hierarchy: Always start from the root and progress logically to the current page
- Handle overflow gracefully: Use the
max-visible-items property to control truncation behavior
- Provide meaningful menu labels: Use the menu-label` attribute to describe the overflow menu purpose