Breadcrumb
<sc-breadcrumb> | ScBreadcrumb
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.
<sc-breadcrumb> <sc-breadcrumb-item>Catalog</sc-breadcrumb-item> <sc-breadcrumb-item>Clothing</sc-breadcrumb-item> <sc-breadcrumb-item>Women's</sc-breadcrumb-item> <sc-breadcrumb-item>Shirts & Tops</sc-breadcrumb-item> </sc-breadcrumb>
import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb'; import ScBreadcrumbItem from '@styledc-dev/styledc/dist/react/breadcrumb-item'; const App = () => ( <ScBreadcrumb> <ScBreadcrumbItem>Catalog</ScBreadcrumbItem> <ScBreadcrumbItem>Clothing</ScBreadcrumbItem> <ScBreadcrumbItem>Women's</ScBreadcrumbItem> <ScBreadcrumbItem>Shirts & Tops</ScBreadcrumbItem> </ScBreadcrumb> );
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.
<sc-breadcrumb> <sc-breadcrumb-item href="https://example.com/home">Homepage</sc-breadcrumb-item> <sc-breadcrumb-item href="https://example.com/home/services">Our Services</sc-breadcrumb-item> <sc-breadcrumb-item href="https://example.com/home/services/digital">Digital Media</sc-breadcrumb-item> <sc-breadcrumb-item href="https://example.com/home/services/digital/web-design">Web Design</sc-breadcrumb-item> </sc-breadcrumb>
import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb'; import ScBreadcrumbItem from '@styledc-dev/styledc/dist/react/breadcrumb-item'; const App = () => ( <ScBreadcrumb> <ScBreadcrumbItem href="https://example.com/home">Homepage</ScBreadcrumbItem> <ScBreadcrumbItem href="https://example.com/home/services">Our Services</ScBreadcrumbItem> <ScBreadcrumbItem href="https://example.com/home/services/digital">Digital Media</ScBreadcrumbItem> <ScBreadcrumbItem href="https://example.com/home/services/digital/web-design">Web Design</ScBreadcrumbItem> </ScBreadcrumb> );
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.
<sc-breadcrumb> <sc-icon name="dot" slot="separator"></sc-icon> <sc-breadcrumb-item>First</sc-breadcrumb-item> <sc-breadcrumb-item>Second</sc-breadcrumb-item> <sc-breadcrumb-item>Third</sc-breadcrumb-item> </sc-breadcrumb> <br /> <sc-breadcrumb> <sc-icon name="arrow-right" slot="separator"></sc-icon> <sc-breadcrumb-item>First</sc-breadcrumb-item> <sc-breadcrumb-item>Second</sc-breadcrumb-item> <sc-breadcrumb-item>Third</sc-breadcrumb-item> </sc-breadcrumb> <br /> <sc-breadcrumb> <span slot="separator">/</span> <sc-breadcrumb-item>First</sc-breadcrumb-item> <sc-breadcrumb-item>Second</sc-breadcrumb-item> <sc-breadcrumb-item>Third</sc-breadcrumb-item> </sc-breadcrumb>
import '@styledc-dev/styledc/dist/components/icon/icon.js'; import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb'; import ScBreadcrumbItem from '@styledc-dev/styledc/dist/react/breadcrumb-item'; const App = () => ( <> <ScBreadcrumb> <sc-icon name="dot" slot="separator" /> <ScBreadcrumbItem>First</ScBreadcrumbItem> <ScBreadcrumbItem>Second</ScBreadcrumbItem> <ScBreadcrumbItem>Third</ScBreadcrumbItem> </ScBreadcrumb> <br /> <ScBreadcrumb> <sc-icon name="arrow-right" slot="separator" /> <ScBreadcrumbItem>First</ScBreadcrumbItem> <ScBreadcrumbItem>Second</ScBreadcrumbItem> <ScBreadcrumbItem>Third</ScBreadcrumbItem> </ScBreadcrumb> <br /> <ScBreadcrumb> <span slot="separator">/</span> <ScBreadcrumbItem>First</ScBreadcrumbItem> <ScBreadcrumbItem>Second</ScBreadcrumbItem> <ScBreadcrumbItem>Third</ScBreadcrumbItem> </ScBreadcrumb> </> );
Prefixes
Use the prefix
slot to add content before any breadcrumb item.
<sc-breadcrumb> <sc-breadcrumb-item> <sc-icon slot="prefix" name="house"></sc-icon> Home </sc-breadcrumb-item> <sc-breadcrumb-item>Articles</sc-breadcrumb-item> <sc-breadcrumb-item>Traveling</sc-breadcrumb-item> </sc-breadcrumb>
import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb'; import ScBreadcrumbItem from '@styledc-dev/styledc/dist/react/breadcrumb-item'; import ScIcon from '@styledc-dev/styledc/dist/react/icon'; const App = () => ( <ScBreadcrumb> <ScBreadcrumbItem> <ScIcon slot="prefix" name="house" /> Home </ScBreadcrumbItem> <ScBreadcrumbItem>Articles</ScBreadcrumbItem> <ScBreadcrumbItem>Traveling</ScBreadcrumbItem> </ScBreadcrumb> );
Suffixes
Use the suffix
slot to add content after any breadcrumb item.
<sc-breadcrumb> <sc-breadcrumb-item>Documents</sc-breadcrumb-item> <sc-breadcrumb-item>Policies</sc-breadcrumb-item> <sc-breadcrumb-item> Security <sc-icon slot="suffix" name="shield-lock"></sc-icon> </sc-breadcrumb-item> </sc-breadcrumb>
import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb'; import ScBreadcrumbItem from '@styledc-dev/styledc/dist/react/breadcrumb-item'; import ScIcon from '@styledc-dev/styledc/dist/react/icon'; const App = () => ( <ScBreadcrumb> <ScBreadcrumbItem>Documents</ScBreadcrumbItem> <ScBreadcrumbItem>Policies</ScBreadcrumbItem> <ScBreadcrumbItem> Security <ScIcon slot="suffix" name="shield-lock"></ScIcon> </ScBreadcrumbItem> </ScBreadcrumb> );
With Dropdowns
Dropdown menus can be placed in a prefix or suffix slot to provide additional options.
<sc-breadcrumb> <sc-breadcrumb-item>Homepage</sc-breadcrumb-item> <sc-breadcrumb-item>Our Services</sc-breadcrumb-item> <sc-breadcrumb-item>Digital Media</sc-breadcrumb-item> <sc-breadcrumb-item> Web Design <sc-dropdown slot="suffix"> <sc-button slot="trigger" size="small" circle> <sc-icon label="More options" name="three-dots"></sc-icon> </sc-button> <sc-menu> <sc-menu-item type="checkbox" checked>Web Design</sc-menu-item> <sc-menu-item type="checkbox">Web Development</sc-menu-item> <sc-menu-item type="checkbox">Marketing</sc-menu-item> </sc-menu> </sc-dropdown> </sc-breadcrumb-item> </sc-breadcrumb>
import { ScBreadcrumb, ScBreadcrumbItem, ScButton, ScDropdown, ScIcon, ScMenu, ScMenuItem } from '@styledc-dev/styledc/dist/react'; const App = () => ( <ScBreadcrumb> <ScBreadcrumbItem>Homepage</ScBreadcrumbItem> <ScBreadcrumbItem>Our Services</ScBreadcrumbItem> <ScBreadcrumbItem>Digital Media</ScBreadcrumbItem> <ScBreadcrumbItem> Web Design <ScDropdown slot="suffix"> <ScButton slot="trigger" size="small" circle> <ScIcon label="More options" name="three-dots"></ScIcon> </ScButton> <ScMenu> <ScMenuItem type="checkbox" checked> Web Design </ScMenuItem> <ScMenuItem type="checkbox">Web Development</ScMenuItem> <ScMenuItem type="checkbox">Marketing</ScMenuItem> </ScMenu> </ScDropdown> </ScBreadcrumbItem> </ScBreadcrumb> );
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@styledc-dev/styledc@1.0.0/cdn/components/breadcrumb/breadcrumb.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@styledc-dev/styledc@1.0.0/cdn/components/breadcrumb/breadcrumb.js';
To import this component using a bundler:
import '@styledc-dev/styledc/dist/components/breadcrumb/breadcrumb.js';
To import this component as a React component:
import ScBreadcrumb from '@styledc-dev/styledc/dist/react/breadcrumb';
Slots
Name | Description |
---|---|
(default) | One or more breadcrumb items to display. |
separator
|
The separator to use between breadcrumb items. Works best with <sc-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.
<sc-icon>