Breadcrumb
Indicate the current page’s location within a navigational hierarchy that automatically adds separators via CSS.
Overview
<template>
<BBreadcrumb :items="breadcrumbItems" />
</template>
<script setup lang="ts">
import type {BreadcrumbItem} from 'bootstrap-vue-next'
import {ref} from 'vue'
const breadcrumbItems = ref<BreadcrumbItem[]>([
{text: 'Admin', href: 'https://getbootstrap.com/'},
{text: 'Manage', href: '#'},
{text: 'Library'},
])
</script>Breadcrumb items
Items are rendered using :items prop. It can be an array of objects to provide link and active state or an array of strings. Links can be href's for anchor tags, or to's for router-links. The active state of last element is automatically set if it is undefined.
Breadcrumb items as array of strings
<template>
<BBreadcrumb :items="breadcrumbStringArray" />
</template>
<script setup lang="ts">
const breadcrumbStringArray = ['Admin', 'Manage', 'Library']
</script>Manually placed items
You may also manually place individual BBreadcrumbItem child components in the default slot of the BBreadcrumb component, as an alternative to using the items prop, for greater control over the content of each item:
<template>
<BBreadcrumb>
<BBreadcrumbItem href="#home"> Home </BBreadcrumbItem>
<BBreadcrumbItem href="#foo">Foo</BBreadcrumbItem>
<BBreadcrumbItem
href="#bar"
@click="alertEvent"
>Bar</BBreadcrumbItem
>
<BBreadcrumbItem active>Baz</BBreadcrumbItem>
</BBreadcrumb>
</template>
<script setup lang="ts">
const alertEvent = (event: MouseEvent) => {
// eslint-disable-next-line no-alert
alert(`Event ${event.target}`)
}
</script>Remember to set the active prop on the last item.
BBreadcrumbItem also supports the various RouterLink props such as to, etc. See the Router Links refererence page for more information.
Slots
Two slots are provided to put additional content before and after the breadcrumb. Use slot prepend to put content before the breadcrumb. Use slot append to put content after the breadcrumb.
<BBreadcrumb>
<BBreadcrumbItem href="#home"> Home </BBreadcrumbItem>
<BBreadcrumbItem href="#foo">Foo</BBreadcrumbItem>
<BBreadcrumbItem href="#bar">Bar</BBreadcrumbItem>
<BBreadcrumbItem active>Baz</BBreadcrumbItem>
<template #prepend><span class="mx-2">prepend text</span></template>
<template #append><span class="mx-2">append text</span></template>
</BBreadcrumb>Component Reference
<BBreadcrumb>
.breadcrumb| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | undefined | ID of the breadcrumb component. When combined with the `useBreadcrumb` composable, it will use this id as a breadcrumb trail instead of the global trail. |
| items | BreadcrumbItemRaw[] | undefined | Array of `BreadCrumbItem`s or strings to render. See above for details. |
| Name | Scope | Description |
|---|---|---|
| append | Content to append to the breadcrumb | |
| default | Content (breadcrumb items) to place in the breadcrumb | |
| prepend | Content to prepend to the breadcrumb |
<BBreadcrumbItem>
.breadcrumb‑item| Prop | Type | Default | Description |
|---|---|---|---|
| aria-current | string | 'location' | Sets the value of the 'aria-current' attribute (when the item is the active item). Supported string values are 'location', 'page', or 'true' |
| text | string | undefined | Text to render in the breadcrumb item |
| Event | Args | Description |
|---|---|---|
| click | click: MouseEvent - Native click event object | Emitted when the breadcrumb item is clicked |
| Name | Scope | Description |
|---|---|---|
| default | Content to place in the breadcrumb item |