Skip to content

Breadcrumb ​

Shows where the page sits in the site hierarchy and lets users go back up a level. The last item is the current page.

Usage ​

Basic usage ​

vue
<script setup>
const items = [
  { label: 'Home', href: '/' },
  { label: 'Projects', href: '/projects' },
  { label: 'SurgeUI', href: '/projects/surgeui' },
  { label: 'Components', href: '/projects/surgeui/components' },
  { label: 'Breadcrumb' }
]
</script>

<template>
  <SuBreadcrumb :items="items" />
</template>

Separators ​

vue
<SuBreadcrumb :items="items" separator="slash" />

Collapsed path ​

Beyond maxItems items, the middle of the path collapses behind a "…" button that expands it.

vue
<SuBreadcrumb :items="items" :max-items="3" />

Home as an icon ​

With iconOnly, the label is still read by screen readers.

vue
<script setup>
import { HomeIcon } from '@heroicons/vue/24/outline'

const items = [
  { label: 'Home', href: '/', icon: HomeIcon, iconOnly: true },
  { label: 'Projects', href: '/projects' },
  { label: 'SurgeUI' }
]
</script>

With Vue Router ​

The item slot replaces an item's rendering, for instance with a RouterLink.

vue
<SuBreadcrumb :items="items">
  <template #item="{ item, current }">
    <span v-if="current" aria-current="page">{{ item.label }}</span>
    <RouterLink v-else :to="item.href">{{ item.label }}</RouterLink>
  </template>
</SuBreadcrumb>

API ​

Props ​

PropTypeDefaultDescription
itemsBreadcrumbItem[][]Path items, from the root to the current page
separator'chevron' | 'slash' | 'dot''chevron'Separator (or separator slot)
maxItemsnumber-Beyond this, the middle of the path collapses
size'sm' | 'md' | 'lg''md'Text size
ariaLabelstring'Breadcrumb' (locale)Navigation name
expandLabelstring'Show full path' (locale)Name of the "…" button
PropertyTypeDescription
labelstringLabel
hrefstringLink (without a link: plain text)
target'_blank' | '_self' | '_parent' | '_top'Link target
iconComponentIcon before the label
iconOnlybooleanVisually hides the label

Slots ​

SlotPropsDescription
item{ item, index, current }Item rendering
separator-Custom separator

Accessibility ​

  • <nav aria-label="Breadcrumb"> containing an ordered list.
  • The current page (last item) has aria-current="page".
  • Separators are hidden from screen readers (aria-hidden).
  • The "…" button is named; once the path expands, focus moves to the first revealed item.
  • In RTL, the chevron is mirrored.

Publié sous licence MIT.