Keyboard shortcut: Ctrl + K
Get started

Breadcrumb

VBreadcrumb displays a navigation trail from an item array and marks the current page using its URL.

Usage

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
]
</script>

<template>
  <VBreadcrumb :items="items" current-path="/app/projects/vectis-ui" />
</template>

Examples

Custom separator

separatorIcon replaces the separator between segments.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'

import slash from '~/assets/img/breadcrumb-slash.svg'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
]
</script>

<template>
  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui"
    :separator-icon="arrowRightAlt"
    label="Trail with an icon separator"
  />

  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui"
    :separator-icon="{ src: slash }"
    label="Trail with an image separator"
  />
</template>

With icons

Each item can include a decorative icon beside its label.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'
import {
  cloud_upload as cloudUpload,
  picture_as_pdf as pictureAsPdf,
  table_chart as tableChart,
} from 'vectis-ui/icons'

const items = [
  { label: 'Uploads', href: '/app/files', icon: cloudUpload },
  { label: 'Reports', href: '/app/files/reports', icon: tableChart },
  { label: 'Third quarter', href: '/app/files/reports/q3', icon: pictureAsPdf },
]
</script>

<template>
  <VBreadcrumb :items="items" current-path="/app/files/reports/q3" />
</template>

Truncation

Beyond maxItems, the trail keeps the first and last two items. An ellipsis menu lists the hidden items.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
  { label: 'Components', href: '/app/projects/vectis-ui/components' },
  { label: 'Breadcrumb', href: '/app/projects/vectis-ui/components/breadcrumb' },
  { label: 'Accessibility', href: '/app/projects/vectis-ui/components/breadcrumb/a11y' },
]
</script>

<template>
  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui/components/breadcrumb/a11y"
    :max-items="4"
  />
</template>

Router

Each segment is a real <a>. A click emits navigate with the item and the event: with Nuxt or Vue Router, call preventDefault() and push item.href. A click with a modifier key emits nothing and still opens a new tab.

vue
<VBreadcrumb
  :items="items"
  :current-path="$route.path"
  @navigate="(item, event) => { event.preventDefault(); $router.push(item.href) }"
/>

API

Props

PropTypeDefault
itemsBreadcrumbItem[]none
Trail items, from the root to the current level.
labelstringnone
Accessible navigation name. Defaults to the dictionary.
currentPathstringnone
URL used to identify the current item. Trailing slashes, query strings and hashes are ignored.
separatorIconIconSourcechevron_right
Separator icon. Mirrors in right-to-left layouts.
maxItemsnumbernone
Truncation threshold, with an effective minimum of 3.
ellipsisLabelstringnone
Accessible ellipsis menu name. Defaults to the dictionary.

Events

EventType
navigate[item: BreadcrumbItem, event: MouseEvent]
Segment followed, from the trail or the ellipsis menu. Receives the item and click event; call preventDefault() for routing. Modified clicks do not emit it.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BreadcrumbItem {
  label: string
  href: string
  icon?: IconSource
}
export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender