Breadcrumbs
KBreadcrumbs component is a navigational aid that displays the user's location within a website's hierarchy, offering a trail of links back to the parent or higher-level pages. Breadcrumbs help users understand their current position in the site and navigate more efficiently.
- Home /
- KButton /
- Non-link item/
- You are here
Props
items
An array of breadcrumb items. Items that are not links, displayed at the end, will not be followed by a divider.
- Home /
- KButton /
- Non-link item/
- You are here
interface BreadcrumbItem {
to?: object | string
text?: string // breadcrumb text that will appear inside of anchor tag
title?: string // will be used for html title attribute on the anchor tag, helpful when text is truncated
key?: string // identifier, must be unique for each breadcrumb item
maxWidth?: string
}
2
3
4
5
6
7
<template>
<KBreadcrumbs :items="breadcrumbItems" />
</template>
<script setup lang="ts">
import { BreadcrumbItem } from '@kong/kongponents'
const breadcrumbItems: BreadcrumbItem[] = [{
key: 'home',
to: { path: '/' },
title: 'Go Home',
text: 'Home',
},
{
key: 'button',
to: { path: '/components/button.html' },
title: 'Go to KButton',
text: 'KButton'
},
{
key: 'not-here',
title: 'Non-link item',
text: 'Non-link item'
},
{
key: 'here',
to: { path: '/components/breadcrumb.html' },
title: 'You are here',
text: 'You are here'
}]
</script>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
The to
property can be a Vue router object or a URL. In most scenarios you will build your breadcrumb items using your Vue application routes.
<template>
<KBreadcrumbs :items="breadcrumbItems" />
</template>
<script lang="ts" setup>
import { BreadcrumbItem } from '@kong/kongponents'
const breadcrumbItems: BreadcrumbItem[] = [{
key: 'google',
to: 'https://google.com',
title: 'Search at Google',
text: 'Google'
},
{
key: 'kongponents',
to: { path: '/' },
title: 'Kongponents',
text: 'Kongponents'
}]
</script>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
itemMaxWidth
Maximum width of each breadcrumb item for truncating to ellipsis. Defaults to 100px
.
<KBreadcrumbs
item-max-width="50px"
:items="breadcrumbItems"
/>
2
3
4
Slots
divider
Content to be displayed between breadcrumb items, defaults to a forward slash /
.
- Home ›
- KButton ›
- Non-link item›
- You are here
<KBreadcrumbs :items="breadcrumbItems">
<template #divider>
<!-- chevron right html symbol -->
›
</template>
</KBreadcrumbs>
2
3
4
5
6
icon
You can slot individual breadcrumb icon content. Each breadcrumb will have an icon slot named after the item key
or index (if no key
provided).
<template>
<KBreadcrumbs :items="breadcrumbItems">
<template #icon-home>
<KongIcon :color="KUI_COLOR_TEXT_DECORATIVE_AQUA" />
</template>
<template #icon-breadcrumb-1>
<DataObjectIcon :color="KUI_COLOR_TEXT_DECORATIVE_PURPLE" />
</template>
</KBreadcrumbs>
</template>
<script setup lang="ts">
import { BreadcrumbItem } from '@kong/kongponents'
const breadcrumbItems: BreadcrumbItem[] = [{
key: 'home',
to: { path: '/' },
title: 'Go Home',
text: 'Home',
},
{
to: { path: '/components/breadcrumbs.html' },
title: 'Go to Breadcrumbs',
text: 'Breadcrumbs'
}]
</script>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26