Breadcrumb

Indicate the current page’s location within a navigational hierarchy that automatically adds separators via CSS.

Overview

HTML
vue
<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>

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.

HTML
vue
<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:

HTML
vue
<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.

HTML
template
<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>
PropTypeDefaultDescription
itemsBreadcrumbItemRaw[]undefined Array of `BreadCrumbItem`s or strings to render. See above for details.
NameScopeDescription
appendContent to append to the breadcrumb
defaultContent (breadcrumb items) to place in the breadcrumb
prependContent to prepend to the breadcrumb
<BBreadcrumbItem>
PropTypeDefaultDescription
aria-currentstring'location' Sets the value of the 'aria-current' attribute (when the item is the active item). Supported string values are 'location', 'page', or 'true'
textstringundefined Text to render in the breadcrumb item
Extensions:
EventArgsDescription
click
click: MouseEvent - Native click event object
Emitted when the breadcrumb item is clicked
NameScopeDescription
defaultContent to place in the breadcrumb item