Skip to content

Breadcrumbs

A trail of places that ends at the current one.

Decision

When Use
A page that drills into a record, where the reader needs a way back Breadcrumbs
A menu of unrelated pages Not the Breadcrumbs

Usage

import { createBreadcrumbs } from './configurationpage?name=myplugin_stolon.js';

var trail = createBreadcrumbs({
    items: [{ label: 'Servers', value: 'servers' }, { label: server.Name }],
    onSelect: function (value) { show(value); }
});

Classes: stolon-breadcrumbs, stolon-breadcrumb-list, stolon-breadcrumb-link, stolon-breadcrumb-current. The handle is { element, getValue, setValue, setItems, destroy }.

Parts: stolon-breadcrumb.

States and Modifiers

  • An item with an href is a link. An item without one is a button that reports itself through onSelect(value, item), and an item with no value reports its label.
  • The last item is the current page. It is plain text with aria-current="page".

Reference

Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.

createBreadcrumbs

function createBreadcrumbs(options?: BreadcrumbsOptions): BreadcrumbsHandle

A trail of places ending at the current one. An item with an href is a link and an item without one is a button that reports itself, and the last item is the current page and is not a control.

Option Type What it does
items BreadcrumbItem[] array of { label, value, href } [optional]
navLabel string aria-label of the nav (default 'Breadcrumb')
onSelect (value: unknown, item: BreadcrumbItem): void function(value, item) called when a button item is pressed [optional]
Handle member Type
getValue (): BreadcrumbItem[]
setValue (next: BreadcrumbItem[]): void
setItems (next: BreadcrumbItem[]): void
destroy (): void
Type What it is
BreadcrumbItem One place in a breadcrumb trail. An item with an href is a link, and one without is a button.
Class What it looks like
stolon-breadcrumb-list Trail of places that wraps on a narrow screen, with chevrons between them
stolon-breadcrumb-link A place that can be opened, as a link or a button that looks like one
stolon-breadcrumb-current The current place, which is plain text

Example

Example Code

<!-- title: Breadcrumbs -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const view = document.getElementById('view');
const mount = document.getElementById('mount');
mount.appendChild(base.createBreadcrumbs({ items: [{ label: 'Servers', value: 'servers' }, { label: 'Library', href: '#library' }, { label: 'Settings' }] }).element);
</script>