Skip to content

CdsBreadcrumbs

Breadcrumbs show the path to the current page in the hierarchy of sections and take you back to any level above in one click. The list is built from the items array or by hand — from CdsBreadcrumbsItem and CdsBreadcrumbsDivider.

Storybook GitLab Figma
Test coverage: 100% — good coverage
API in specs
35 / 35 props, events, slots and exposed members with a test
Test cases
55 unit · 0 browser
Known bugs
8 pinned by an it.fails test
Code coverage
100% lines · 96.9% branches measured in v4.0.0-alpha.13
A11y (axe)
8 recommendations in 9 stories measured in v4.0.0-alpha.11

To switch between sections of the same level, use CdsTabs; for a link styled as text inside a paragraph, use CdsLink; and to move through the steps of a process, use CdsSteps.

Anatomy ​

Breadcrumbs are a ul list where links to the levels of the hierarchy alternate with dividers. The last item marks the current page and is not clickable, and an icon can precede the list.

Variations ​

Items ​

The items array builds the breadcrumbs automatically: a string turns into text, an object turns into a link with href or to. The component marks the last item as the current page itself: it disables the link and paints it in a neutral color.

Divider ​

By default the items are separated by /. The divider prop replaces the character, and the divider slot replaces the whole markup — with a chevron icon, for example.

Icon ​

The icon prop renders an icon before the list — a sign of the root section, for example. The prepend slot replaces it with arbitrary content.

Slots ​

Slots override parts of the list without giving up the automatic assembly from items. The title, divider and item slots receive item and index, so the content can be changed for every item separately.

SlotDescription
prependContent before the list. Replaces the icon from icon
titleItem text — a shared template for all items
dividerDivider content. Replaces the character from divider
itemThe whole item — your own markup instead of CdsBreadcrumbsItem
defaultContent after the items from items; used for manual assembly

Manual assembly ​

When the path is not described by a flat array — you need your own handlers or non-standard items — build the list in the default slot from CdsBreadcrumbsItem and CdsBreadcrumbsDivider. Mark the current page with disabled, and limit a long title with max-width — the text is truncated with an ellipsis.

Guidelines ​

Scenarios ​

Section navigation ​

Breadcrumbs lead the user through the catalog tree: links in the list open deeper sections, a click on a crumb returns one level up. In an application with vue-router, pass to to the items instead of handlers — the navigation and the active state of the link work on their own.

Long path ​

Collapse a deep hierarchy down to the first level, an ellipsis and the last two steps — the path stays on a single line. A click on the ellipsis expands the full list.

API ​

CdsBreadcrumbs ​

Props

NameTypeDefaultDescription
activeClassstring | undefined—Class applied to the component when it is in the active state
activeColorstring | undefined—Color of the component in its active state
baseColorstring | undefined—Color of the component in its inactive state
bgColorstring | undefined—Background color of the component
colorstring | undefined—Component color
disabledboolean | null | undefinednullDisabled state
dividerstring | undefined'/'Divider between the child components
iconIconValue | undefined—Icon displayed next to the component
itemsreadonly BreadcrumbItem[] | undefined[]Array of strings or objects used to build the child components automatically
tagstring | JSXComponent<any> | undefined'ul'Custom HTML tag or component to render
textColorstring | undefined—Text color of the component

Slots

NameTypeDescription
defaultanyDefault content
divider{ item: BreadcrumbItem; index: number; }Divider content between the items; can be overridden for each item
item{ item: InternalBreadcrumbItem; index: number; }Item content; can be overridden for each item
prependanyContent at the start
title{ item: InternalBreadcrumbItem; index: number; }Content inside each item; can be overridden for each item

CdsBreadcrumbsDivider ​

Props

NameTypeDefaultDescription
dividerstring | number | undefined—Divider

Slots

NameTypeDescription
defaultanyDefault content

CdsBreadcrumbsItem ​

Props

NameTypeDefaultDescription
activeboolean | undefined—Active state of the component; usually marks the current page in the navigation
activeClassstring | undefined—Class applied to the component when it is in the active state
activeColorstring | undefined—Color of the component in its active state
baseColorstring | undefined—Color of the component in its inactive state
bgColorstring | undefined—Background color of the component
colorstring | undefined—Component color
disabledboolean | null | undefinednullDisabled state
exactboolean | undefined—If true, the active state applies only on an exact route match
hrefstring | undefined—The href attribute of the link. When set, the component behaves as a regular link
maxWidthstring | number | undefined—Maximum component width
replaceboolean | undefined—If true, navigation replaces the current history entry instead of pushing a new one
tagstring | JSXComponent<any> | undefined'li'Custom HTML tag or component to render
textColorstring | undefined—Text color of the component
titlestring | undefined—Item title displayed in the component
toLinkTo | undefined—Target route or route location object for RouterLink. When set, the component behaves as a RouterLink
widthstring | number | undefined—Component width

Slots

NameTypeDescription
defaultanyDefault content