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.
| Slot | Description |
|---|---|
prepend | Content before the list. Replaces the icon from icon |
title | Item text — a shared template for all items |
divider | Divider content. Replaces the character from divider |
item | The whole item — your own markup instead of CdsBreadcrumbsItem |
default | Content 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
| Name | Type | Default | Description |
|---|---|---|---|
activeClass | string | undefined | — | Class applied to the component when it is in the active state |
activeColor | string | undefined | — | Color of the component in its active state |
baseColor | string | undefined | — | Color of the component in its inactive state |
bgColor | string | undefined | — | Background color of the component |
color | string | undefined | — | Component color |
disabled | boolean | null | undefined | null | Disabled state |
divider | string | undefined | '/' | Divider between the child components |
icon | IconValue | undefined | — | Icon displayed next to the component |
items | readonly BreadcrumbItem[] | undefined | [] | Array of strings or objects used to build the child components automatically |
tag | string | JSXComponent<any> | undefined | 'ul' | Custom HTML tag or component to render |
textColor | string | undefined | — | Text color of the component |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Default 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 |
prepend | any | Content at the start |
title | { item: InternalBreadcrumbItem; index: number; } | Content inside each item; can be overridden for each item |
CdsBreadcrumbsDivider
Props
| Name | Type | Default | Description |
|---|---|---|---|
divider | string | number | undefined | — | Divider |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Default content |
CdsBreadcrumbsItem
Props
| Name | Type | Default | Description |
|---|---|---|---|
active | boolean | undefined | — | Active state of the component; usually marks the current page in the navigation |
activeClass | string | undefined | — | Class applied to the component when it is in the active state |
activeColor | string | undefined | — | Color of the component in its active state |
baseColor | string | undefined | — | Color of the component in its inactive state |
bgColor | string | undefined | — | Background color of the component |
color | string | undefined | — | Component color |
disabled | boolean | null | undefined | null | Disabled state |
exact | boolean | undefined | — | If true, the active state applies only on an exact route match |
href | string | undefined | — | The href attribute of the link. When set, the component behaves as a regular link |
maxWidth | string | number | undefined | — | Maximum component width |
replace | boolean | undefined | — | If true, navigation replaces the current history entry instead of pushing a new one |
tag | string | JSXComponent<any> | undefined | 'li' | Custom HTML tag or component to render |
textColor | string | undefined | — | Text color of the component |
title | string | undefined | — | Item title displayed in the component |
to | LinkTo | undefined | — | Target route or route location object for RouterLink. When set, the component behaves as a RouterLink |
width | string | number | undefined | — | Component width |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Default content |