vael-ui v0.5.7

Navigation & menus

Layout

Breadcrumb

A trail of links from the top of the site down to the current page. Use it on pages deep in a hierarchy.

Install

import { Breadcrumb } from 'vael-ui'

Playground

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { Breadcrumb, BreadcrumbItem, BreadcrumbSeparator } from 'vael-ui'
</script>

<template>
  <Breadcrumb>
    <BreadcrumbItem href="/">Home</BreadcrumbItem>
    <BreadcrumbSeparator />
    <BreadcrumbItem href="/docs">Docs</BreadcrumbItem>
    <BreadcrumbSeparator />
    <BreadcrumbItem current>Breadcrumb</BreadcrumbItem>
  </Breadcrumb>
</template>

Props

NameTypeDefaultDescription
itemsreadonly T[]Crumbs to render, with separators added between them. Omit to compose children in the default slot.
ariaLabelstringOverrides the default localized "Breadcrumb" nav landmark label.
wrapbooleanfalseWraps crumbs onto multiple lines instead of scrolling one line horizontally on overflow.
motionBreadcrumbMotionHow it moves: its appearance, crumb by crumb ({ initial: { item: { opacity: 0, x: -4 } }, stagger: 0.03 }). Crumbs a new path adds or removes come and go the same way. false turns its own animation off.
uiPartial<Record<'root' | 'list' | 'icon', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
defaultanyBreadcrumbItem and BreadcrumbSeparator children that you interleave. Has no effect when you pass items.
item{ item: T; index: number; }Custom label content for each crumb when you pass items. Falls back to plain text.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Breadcrumb: its appearance, crumb by crumb.

<Breadcrumb
  :motion="{ initial: { item: { opacity: 0, y: 8 } }, stagger: 0.04 }"
/>
NameTypeDescription
initialexitrootitemSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
staggerleavingappearnumber | 'pop' | 'hold' | booleanItems coming in together start stagger seconds apart. A leaving item lifts out so the rest close the gap ('pop'), or keeps its space until it's gone ('hold'). appear: true also brings in the items already there when it mounts.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

Follows the Breadcrumb pattern from the WAI-ARIA Authoring Practices Guide.

KeyAction
TabShiftTabMoves focus between the crumb links.
  • Renders a <nav> landmark labeled with a translated “Breadcrumb”; ariaLabel overrides it. The crumbs are an <ol>.
  • The current crumb, the last one by default, is plain text with aria-current="page", not a link.
  • Separators and item icons are aria-hidden.
  • Give each link an href, or to for a router link, through attrs or on BreadcrumbItem.