core
Breadcrumb
Navigation breadcrumbs showing page hierarchy
Source
import Markdoc from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createContentModelSchema, createComponentRenderable, renderNodes } from '../lib/index.js';
export const BREADCRUMB_AUTO_SENTINEL = '__breadcrumb-auto';
export const breadcrumbSchema = {
type: 'BreadcrumbList',
lists: ['itemListElement'],
children: {
'breadcrumb-item': {
type: 'ListItem',
property: 'itemListElement',
properties: { name: 'name', url: 'item' },
generated: { position: 'index' },
},
},
} as const;
export const breadcrumb = createContentModelSchema({
schema: breadcrumbSchema,
attributes: {
separator: {
type: String,
required: false,
default: '/',
description: 'Character between breadcrumb items',
},
auto: {
type: Boolean,
required: false,
default: false,
description: 'Automatically generate from page hierarchy',
},
},
contentModel: (attrs) => {
if (attrs.auto) {
return { type: 'sequence' as const, fields: [] };
}
return {
type: 'sequence' as const,
fields: [{ name: 'list', match: 'list' as const, optional: true, greedy: true }],
};
},
transform(resolved, attrs, config) {
const separatorMeta = new Tag('meta', { content: attrs.separator });
if (attrs.auto) {
const sentinelMeta = new Tag('meta', {
'data-field': BREADCRUMB_AUTO_SENTINEL,
content: 'true',
});
const emptyList = new Tag('ol', {}, []);
return createComponentRenderable({
rune: 'breadcrumb',
tag: 'nav',
properties: {
separator: separatorMeta,
},
refs: {
items: emptyList,
},
children: [sentinelMeta, emptyList],
});
}
const children = renderNodes(resolved.list, config);
const listItems: any[] = [];
for (const node of children.toArray()) {
if (Tag.isTag(node) && (node.name === 'ul' || node.name === 'ol')) {
for (const li of (node as any).children) {
if (Tag.isTag(li) && li.name === 'li') {
const link = (li as any).children.find((c: any) => Tag.isTag(c) && c.name === 'a');
if (link) {
const nameSpan = new Tag('span', { hidden: true }, link.children);
const urlLink = new Tag('a', { href: link.attributes.href }, link.children);
listItems.push(
createComponentRenderable({
rune: 'breadcrumb-item',
tag: 'li',
properties: {
name: nameSpan,
url: urlLink,
},
children: [nameSpan, urlLink],
}) as any,
);
} else {
const text = li.children
.filter((c: any) => typeof c === 'string')
.join('')
.trim();
const nameSpan = new Tag('span', {}, text ? [text] : li.children);
listItems.push(
createComponentRenderable({
rune: 'breadcrumb-item',
tag: 'li',
properties: {
name: nameSpan,
},
children: [nameSpan],
}) as any,
);
}
}
}
}
}
const itemsList = new Tag('ol', {}, listItems);
return createComponentRenderable({
rune: 'breadcrumb',
tag: 'nav',
properties: {
separator: separatorMeta,
},
refs: {
items: itemsList,
},
children: [itemsList],
});
},
});
Navigation breadcrumbs from a list of links. Each linked item is a navigable breadcrumb, and the last item (without a link) represents the current page.
Basic usage
A breadcrumb trail using the default / separator.
{% breadcrumb %}
- [Home](/)
- [Getting started](/docs/getting-started)
- [Tabs](/runes/tabs)
- Breadcrumb
{% /breadcrumb %}<nav data-rune="breadcrumb" data-rune-fields="{"separator":"/"}" typeof="BreadcrumbList" data-schema-lists="["itemListElement"]">
<ol data-name="items">
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span hidden data-field="name" property="name">Home</span>
<a href="/" data-field="url" property="item">Home</a>
<meta property="position" content="1">
</li>
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span hidden data-field="name" property="name">Getting started</span>
<a href="/docs/getting-started" data-field="url" property="item">Getting started</a>
<meta property="position" content="2">
</li>
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span hidden data-field="name" property="name">Tabs</span>
<a href="/runes/tabs" data-field="url" property="item">Tabs</a>
<meta property="position" content="3">
</li>
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span data-field="name" property="name">Breadcrumb</span>
<meta property="position" content="4">
</li>
</ol>
</nav><nav class="rf-breadcrumb" typeof="BreadcrumbList" data-schema-lists="["itemListElement"]" data-separator="/" data-elevation="flush" data-rune="breadcrumb" data-density="minimal" style="--separator: "/"">
<ol data-name="items" class="rf-breadcrumb__items">
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span hidden data-field="name" property="name">Home</span>
<a href="/" data-field="url" property="item">Home</a>
<meta property="position" content="1" />
</li>
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span hidden data-field="name" property="name">Getting started</span>
<a href="/docs/getting-started" data-field="url" property="item">Getting started</a>
<meta property="position" content="2" />
</li>
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span hidden data-field="name" property="name">Tabs</span>
<a href="/runes/tabs" data-field="url" property="item">Tabs</a>
<meta property="position" content="3" />
</li>
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span data-field="name" property="name">Breadcrumb</span>
<meta property="position" content="4" />
</li>
</ol>
</nav>How Markdown is read
| You write | It becomes |
|---|---|
| A list | The trail, one crumb per item, in order |
| An item that is a link | A crumb that links to that page |
| An item without a link | A plain-text crumb, normally the current page |
Custom separator
Use the separator attribute to change the divider between items.
{% breadcrumb separator="›" %}
- [Home](/)
- [Getting started](/docs/getting-started)
- Current page
{% /breadcrumb %}<nav data-rune="breadcrumb" data-rune-fields="{"separator":"›"}" typeof="BreadcrumbList" data-schema-lists="["itemListElement"]">
<ol data-name="items">
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span hidden data-field="name" property="name">Home</span>
<a href="/" data-field="url" property="item">Home</a>
<meta property="position" content="1">
</li>
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span hidden data-field="name" property="name">Getting started</span>
<a href="/docs/getting-started" data-field="url" property="item">Getting started</a>
<meta property="position" content="2">
</li>
<li data-rune="breadcrumb-item" typeof="ListItem" property="itemListElement">
<span data-field="name" property="name">Current page</span>
<meta property="position" content="3">
</li>
</ol>
</nav><nav class="rf-breadcrumb" typeof="BreadcrumbList" data-schema-lists="["itemListElement"]" data-separator="›" data-elevation="flush" data-rune="breadcrumb" data-density="minimal" style="--separator: "›"">
<ol data-name="items" class="rf-breadcrumb__items">
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span hidden data-field="name" property="name">Home</span>
<a href="/" data-field="url" property="item">Home</a>
<meta property="position" content="1" />
</li>
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span hidden data-field="name" property="name">Getting started</span>
<a href="/docs/getting-started" data-field="url" property="item">Getting started</a>
<meta property="position" content="2" />
</li>
<li class="rf-breadcrumb-item" typeof="ListItem" property="itemListElement" data-rune="breadcrumb-item" data-density="full">
<span data-field="name" property="name">Current page</span>
<meta property="position" content="3" />
</li>
</ol>
</nav>Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
separator | string | — | Character between breadcrumb items |
auto | boolean | — | Automatically generate from page hierarchy |
Universal attributes
bg
The background layer: image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.
| Attribute | Type | Required | Description |
|---|---|---|---|
bg | string | — | Background preset applied to this block |
bg-from | string | — | Gradient start colour — a semantic token name (→ var(--rf-color-*)) |
bg-gradient | "to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl" | — | Gradient direction (bounded named set) |
bg-gradient-type | "linear" | "radial" | "conic" | — | Gradient type |
bg-to | string | — | Gradient end colour — a semantic token name |
bg-via | string | — | Optional middle gradient stop — a semantic token name |
scrim | "top" | "bottom" | "left" | "right" | "none" | — | Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim |
scrim-blur | "none" | "sm" | "md" | "lg" | — | Frost scrim blur amount |
scrim-strength | "sm" | "md" | "lg" | — | Gradient scrim strength |
scrim-tone | "dark" | "light" | — | Whether the scrim darkens (for light text) or lightens (for dark text) |
scrim-type | "gradient" | "frost" | — | Scrim treatment: gradient (default) or frost (backdrop blur) |
elevation
How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.
| Attribute | Type | Required | Description |
|---|---|---|---|
elevation | "sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg" | — | Surface depth, from sunken to overlay. Deprecated: none, sm, md and lg (read as flat, raised, raised and floating) |
inset
Internal padding override.
| Attribute | Type | Required | Description |
|---|---|---|---|
inset | "flush" | "tight" | "default" | "loose" | "breathe" | — | Inner padding of this block |
motion
Scroll-reveal entrance. You choose its character; the theme decides how it moves.
| Attribute | Type | Required | Description |
|---|---|---|---|
reveal | "none" | "fade" | "slide" | "scale" | "blur" | — | Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography |
stagger | boolean | — | Cascade this block's items in as it reveals (no-op on single-child runes) |
spacing
Block-level rhythm override.
| Attribute | Type | Required | Description |
|---|---|---|---|
spacing | "flush" | "tight" | "default" | "loose" | "breathe" | — | Vertical spacing above and below this block |
substrate
Generated pattern fills behind the content, drawn by the theme.
| Attribute | Type | Required | Description |
|---|---|---|---|
substrate | "dots" | "grid" | "lines" | "cross" | "checker" | "none" | — | Generated surface pattern |
substrate-fill | "inherit" | "inset" | — | Surface fill the pattern sits on (full colour stays with tint) |
substrate-opacity | "sm" | "md" | "lg" | — | Pattern ink strength |
substrate-size | "sm" | "md" | "lg" | — | Pattern cell size |
substrate-target | "self" | "media" | — | Which surface the pattern fills (overrides the rune/theme default) |
tint
Per-rune colour override: a named tint from the theme registry, with inline per-token overrides layered on top.
| Attribute | Type | Required | Description |
|---|---|---|---|
tint | string | — | Color tint preset applied to this block |
tint-mode | "auto" | "dark" | "light" | — | Whether the tint adapts to auto, dark, or light mode |
width
The track a block rune occupies.
| Attribute | Type | Required | Description |
|---|---|---|---|
width | "compact" | "narrow" | "content" | "wide" | "full" | — | Maximum width constraint for this block |
| Not available | Why |
|---|---|
| dropcap, reading | this rune declares no prose body |
| frame | this rune declares neither a `frameTarget` nor a media section |
| prominence | this rune has no page-section header or featured quotation |