Breadcrumb
<sl-breadcrumb> | SlBreadcrumb
Breadcrumbs provide a group of links so users can easily navigate a website’s hierarchy.
Breadcrumbs are usually placed before a page’s main content with the current page shown last to indicate the user’s position in the navigation.
<sl-breadcrumb> <sl-breadcrumb-item>Catalog</sl-breadcrumb-item> <sl-breadcrumb-item>Clothing</sl-breadcrumb-item> <sl-breadcrumb-item>Women's</sl-breadcrumb-item> <sl-breadcrumb-item>Shirts & Tops</sl-breadcrumb-item> </sl-breadcrumb>
Examples
Breadcrumb Links
By default, breadcrumb items are rendered as buttons so you can use them to navigate single-page applications. In this case, you’ll need to add event listeners to handle clicks.
For websites, you’ll probably want to use links instead. You can make any breadcrumb item a link by applying
an href
attribute to it. Now, when the user activates it, they’ll be taken to the corresponding
page — no event listeners required.
<sl-breadcrumb> <sl-breadcrumb-item href="https://example.com/home">Homepage</sl-breadcrumb-item> <sl-breadcrumb-item href="https://example.com/home/services">Our Services</sl-breadcrumb-item> <sl-breadcrumb-item href="https://example.com/home/services/digital">Digital Media</sl-breadcrumb-item> <sl-breadcrumb-item href="https://example.com/home/services/digital/web-design">Web Design</sl-breadcrumb-item> </sl-breadcrumb>
Custom Separators
Use the separator
slot to change the separator that goes between breadcrumb items. Icons work
well, but you can also use text or an image.
<sl-breadcrumb> <sl-icon name="period" slot="separator"></sl-icon> <sl-breadcrumb-item>First</sl-breadcrumb-item> <sl-breadcrumb-item>Second</sl-breadcrumb-item> <sl-breadcrumb-item>Third</sl-breadcrumb-item> </sl-breadcrumb> <br /> <sl-breadcrumb> <sl-icon name="arrow-right" slot="separator"></sl-icon> <sl-breadcrumb-item>First</sl-breadcrumb-item> <sl-breadcrumb-item>Second</sl-breadcrumb-item> <sl-breadcrumb-item>Third</sl-breadcrumb-item> </sl-breadcrumb> <br /> <sl-breadcrumb> <span slot="separator">/</span> <sl-breadcrumb-item>First</sl-breadcrumb-item> <sl-breadcrumb-item>Second</sl-breadcrumb-item> <sl-breadcrumb-item>Third</sl-breadcrumb-item> </sl-breadcrumb>
Prefixes
Use the prefix
slot to add content before any breadcrumb item.
<sl-breadcrumb> <sl-breadcrumb-item> <sl-icon slot="prefix" name="house"></sl-icon> Home </sl-breadcrumb-item> <sl-breadcrumb-item>Articles</sl-breadcrumb-item> <sl-breadcrumb-item>Traveling</sl-breadcrumb-item> </sl-breadcrumb>
Suffixes
Use the suffix
slot to add content after any breadcrumb item.
<sl-breadcrumb> <sl-breadcrumb-item>Documents</sl-breadcrumb-item> <sl-breadcrumb-item>Policies</sl-breadcrumb-item> <sl-breadcrumb-item> Security <sl-icon slot="suffix" name="shield-xmark"></sl-icon> </sl-breadcrumb-item> </sl-breadcrumb>
With Dropdowns
Dropdown menus can be placed in a prefix or suffix slot to provide additional options.
<sl-breadcrumb> <sl-breadcrumb-item>Homepage</sl-breadcrumb-item> <sl-breadcrumb-item>Our Services</sl-breadcrumb-item> <sl-breadcrumb-item>Digital Media</sl-breadcrumb-item> <sl-breadcrumb-item> Web Design <sl-dropdown slot="suffix"> <sl-button slot="trigger" size="small" circle> <sl-icon label="More options" name="ellipsis"></sl-icon> </sl-button> <sl-menu> <sl-menu-item type="checkbox" checked>Web Design</sl-menu-item> <sl-menu-item type="checkbox">Web Development</sl-menu-item> <sl-menu-item type="checkbox">Marketing</sl-menu-item> </sl-menu> </sl-dropdown> </sl-breadcrumb-item> </sl-breadcrumb>
Slots
Name | Description |
---|---|
(default) | One or more breadcrumb items to display. |
separator
|
The separator to use between breadcrumb items. Works best with <sl-icon> . |
Learn more about using slots.
Properties
Name | Description | Reflects | Type | Default |
---|---|---|---|---|
label
|
The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by screen readers and other assistive devices to provide more context for users. |
string
|
''
|
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Parts
Name | Description |
---|---|
base |
The component’s base wrapper. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<sl-icon>