Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

bread-crumb

Hierarchical navigation trail. Wraps existing <ol> markup HTML-first inside a <nav>, or auto-generates from window.location.pathname. Emits BreadcrumbList JSON-LD for SEO.

Overview

The <bread-crumb> component formalizes the <nav class="breadcrumb"> pattern. It takes plain <ol> markup as the HTML-first source of truth, keeps aria-current="page" on the final crumb, emits a BreadcrumbList JSON-LD <script> for SEO, and turns data-collapsed into an expandable trail. With data-from-pathname it can also build the trail from window.location.pathname.

Attributes

AttributeTypeDefaultDescription
data-from-pathname boolean — Auto-build the trail from window.location.pathname. A Home crumb comes first; each URL-decoded segment becomes a crumb (Title-Cased fallback).
data-current-label string — Label for the final (current page) crumb when auto-generating. Wins over .labels.
data-separator string theme token (›) Separator glyph: chevron, arrow, dot, or pipe. Unset uses the --sep-breadcrumb token.
data-collapsed boolean — Hide the middle crumbs, keeping the first crumb, the parent (second-to-last) and the current page. With four or more crumbs an ellipsis button reveals the rest.
data-jsonld string on BreadcrumbList JSON-LD emission. Set to off to skip.

Child attributes

AttributeOnDescription
data-truncated <li> Truncate the crumb's link or label with an ellipsis (max 10rem).

Properties

PropertyTypeDescription
labels Record<string, string> Segment → label map for data-from-pathname. Keys may be a full pathname ('/docs/elements/'), a pathname without the trailing slash, or a single segment; '/' or 'home' relabels Home. Assigning re-renders the trail.

Events

EventDetailDescription
bread-crumb:upgraded — Fired after setup completes.
bread-crumb:toggle { expanded } Fired when the collapse button expands or collapses the trail.

Usage

HTML-first

Wrap the component in a <nav> with an aria-label so the landmark exists before (and without) JavaScript. Mark the last crumb aria-current="page"; the component keeps it in sync.

Separators

Truncated crumb

Collapsed

With data-collapsed the first crumb, the parent and the current page stay visible. The component inserts a <button aria-expanded="false"> named "Show full path" after the first crumb; pressing it reveals the hidden crumbs and pressing it again hides them. Without JavaScript a decorative ellipsis stands in for the hidden crumbs.

Auto from pathname

Skip the markup and let the component infer the trail. data-current-label gives the final crumb a friendly label:

Override segment labels

For non-trivial slugs, assign a label map via the .labels property:

Progressive Enhancement

  1. HTML. The wrapping <nav aria-label> and the <ol><li> structure are the semantic anchor. Without JS or CSS, the trail is a labelled landmark containing a navigable list of links.
  2. CSS. VB's bread-crumb styles apply token-driven separators, truncation, collapse, hover states, and theme-aware colors via the element selector — no class needed. The equivalent class-based, zero-JS pattern is nav.breadcrumb.
  3. JS. The component keeps aria-current="page" on the last crumb, adds the collapse button, supports auto-generation, and emits BreadcrumbList JSON-LD.

Accessibility

  • The landmark comes from the wrapping <nav aria-label="Breadcrumb">. If you omit it, the component falls back to role="navigation" and aria-label="Breadcrumb" on itself (only with JavaScript). Inside a <nav> it adds no role, so there is never a nested duplicate landmark.
  • When a page has more than one breadcrumb or navigation landmark, give each a distinct aria-label.
  • The final crumb is announced as the current page via aria-current="page", on either an <a> or a <span>.
  • Separators and the no-JS collapse ellipsis are CSS-generated with empty alternative text, so screen readers do not announce them.
  • The collapse toggle is a real <button> with aria-expanded, so hidden crumbs stay reachable by keyboard and assistive technology.
  • Use data-truncated sparingly: the full label is still read by screen readers, but sighted users only see the start of it.

SEO

By default the component appends a <script type="application/ld+json"> child containing a BreadcrumbList object derived from the rendered trail. Item URLs are each link's resolved href, so relative links (../) and <base> are honoured; the current-page crumb has no URL. Set data-jsonld="off" when the document already exposes breadcrumbs through another mechanism.

↑