sp-breadcrumb-item

compact true false
label
max-visible-items
Overview API

Overview

Section titled Overview

For use within an <sp-breadcrumbs> element, an <sp-breadcrumb-item> represents a single item in a breadcrumbs list. The default slot contains the main content of the breadcrumb item.

Usage

Section titled Usage

See it on NPM! How big is this package in your project?

yarn add @spectrum-web-components/breadcrumbs

Import the side effectful registration of <sp-breadcrumb-item> as follows:

import '@spectrum-web-components/breadcrumbs/sp-breadcrumb-item.js';

When looking to leverage the BreadcrumbItem base class as a type and/or for extension purposes, do so via:

import { BreadcrumbItem } from '@spectrum-web-components/breadcrumbs';

Anatomy

Section titled Anatomy

The breadcrumb item consists of the following:

  • A clickable anchor (<a>) that contains the breadcrumb text and handles navigation
  • Text content as the main label displayed in the default slot, which becomes the clickable link text
  • A separator consisting of a chevron UI icon component (<sp-icon-chevron100>) that visually separates breadcrumb items
  • An optional action menu for displaying overflowed breadcrumb items

Options

Section titled Options

Value or href attributes

Section titled Value or href attributes

When using the href attribute instead of the value attribute, the breadcrumb item behaves as a regular anchor link.

Value
<sp-breadcrumbs>
    <sp-breadcrumb-item value="home">Home</sp-breadcrumb-item>
    <sp-breadcrumb-item value="trend">Trend</sp-breadcrumb-item>
    <sp-breadcrumb-item value="assets">March 2019 Assets</sp-breadcrumb-item>
</sp-breadcrumbs>
Link
<sp-breadcrumbs>
    <sp-breadcrumb-item href="/home">Home</sp-breadcrumb-item>
    <sp-breadcrumb-item href="/trend">Trend</sp-breadcrumb-item>
    <sp-breadcrumb-item href="/assets">March 2019 Assets</sp-breadcrumb-item>
</sp-breadcrumbs>

With menu content

Section titled With menu content

When breadcrumbs overflow, <sp-breadcrumbs> will create an <sp-breadcrumb-item> with an <sp-action-menu> that contains the full list of breadcrumb items in reading order.

<sp-breadcrumbs max-visible-items="2">
    <sp-breadcrumb-item slot="root" value="your_stuff">
        Your stuff
    </sp-breadcrumb-item>
    <sp-breadcrumb-item value="team">Files</sp-breadcrumb-item>
    <sp-breadcrumb-item value="trend">Trend</sp-breadcrumb-item>
    <sp-breadcrumb-item value="winter">Winter</sp-breadcrumb-item>
    <sp-breadcrumb-item value="assets">Assets</sp-breadcrumb-item>
    <sp-breadcrumb-item value="18x24">18x24</sp-breadcrumb-item>
</sp-breadcrumbs>

States

Section titled States

Disabled

Section titled Disabled

An sp-breadcrumb-item can have a disabled state which disables the events from that item.

<sp-breadcrumbs>
    <sp-breadcrumb-item disabled value="home">Home</sp-breadcrumb-item>
    <sp-breadcrumb-item value="trend">Trend</sp-breadcrumb-item>
    <sp-breadcrumb-item value="assets">March 2019 Assets</sp-breadcrumb-item>
</sp-breadcrumbs>

Accessibility

Section titled Accessibility

The <sp-breadcrumb-item> component provides the following accessibility features:

  • Automatically applies role="listitem" to ensure proper semantic meaning for assistive technologies
  • The last breadcrumb item automatically receives aria-current="page" to indicate the current location
  • Applies aria-disabled="true" when the disabled property is set
  • Each breadcrumb item is keyboard accessible with tabindex="0"
  • Supports Enter key activation for navigation

Best practices

Section titled Best practices
  • Provide meaningful text content: Ensure each breadcrumb item has descriptive and meaningful labels
  • Use proper hierarchy: Place breadcrumb items in the correct order from root to current page
  • Handle navigation events: Listen for the breadcrumb-select event when using value instead of href
  • Keep labels concise: Use short, descriptive labels that clearly identify each level

API

Attributes and Properties

Section titled Attributes and Properties
Property Attribute Type Default Description disabled disabled boolean false Disable this control. It will not receive focus or events download download string | undefined Causes the browser to treat the linked URL as a download. href href string | undefined The URL that the hyperlink points to. label label string | undefined An accessible label that describes the component. It will be applied to aria-label, but not visually rendered. referrerpolicy referrerpolicy | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url' | undefined How much of the referrer to send when following the link. rel rel string | undefined The relationship of the linked URL as space-separated link types. tabIndex tabIndex number The tab index to apply to this control. See general documentation about the tabindex HTML property target target '_blank' | '_parent' | '_self' | '_top' | undefined Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>). value value string | undefined undefined