Skip to content

Breadcrumb

WxBreadcrumb is the trail above the title of a screen: where this record sits, and the way back up. It renders a <nav> around an ordered list, because a trail read out of order is not a trail.

The default separator
An icon separator
Small, with another character

Usage

vue
<template>
  <wx-breadcrumb>
    <wx-breadcrumb-item href="/admin" icon="home">Dashboard</wx-breadcrumb-item>
    <wx-breadcrumb-item href="/admin/pages">Pages</wx-breadcrumb-item>
    <wx-breadcrumb-item>About us</wx-breadcrumb-item>
  </wx-breadcrumb>
</template>

The last crumb links nowhere, and that is how it is recognised: a crumb with no href and no as is the page you are on, and gets aria-current="page". Pass current to say so explicitly — for a trail whose last crumb is still a link.

Separators

A character by default, an icon when one is named:

vue
<template>
  <wx-breadcrumb separator="›">…</wx-breadcrumb>
  <wx-breadcrumb separator-icon="chevron-right">…</wx-breadcrumb>
</template>

Routing

Like Menu, crumbs render through whatever you give as:

vue
<template>
  <wx-breadcrumb-item :as="RouterLink" to="/admin/pages">Pages</wx-breadcrumb-item>
</template>

Building the trail from the route usually beats writing it out by hand:

vue
<template>
  <wx-breadcrumb separator-icon="chevron-right">
    <wx-breadcrumb-item
      v-for="crumb in crumbs"
      :key="crumb.to"
      :as="RouterLink"
      :to="crumb.to"
      :current="crumb.to === route.path"
    >
      {{ crumb.title }}
    </wx-breadcrumb-item>
  </wx-breadcrumb>
</template>
PropTypeDefaultDescription
separatorstring'/'Character drawn between items
separatorIconIconNameIcon drawn instead of that character
size'sm' | 'md''md'Text size of the trail
labelstring'Breadcrumb'Accessible name of the landmark
PropTypeDefaultDescription
hrefstringWhere the crumb points
targetstringLink target; _blank gets a safe rel
asstring | ComponentRenders through another component
iconIconNameIcon before the label
currentbooleanby hrefMarks the crumb as the page you are on

Events: click (MouseEvent).

Slots: default — the label.

Released under the MIT License.