Skip to content
Page

Breadcrumb

Trail of links to the current page.

import {
Breadcrumb,
BreadcrumbList,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/BreadcrumbExample.tsx
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@pelagornis/page/components";
export default function BreadcrumbDemo() {
return (
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">Home</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="/components/">Components</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
);
}

Breadcrumb is composed from parts that share React state. Children written in MDX are rendered as separate islands, so the parts can’t reach each other. Put the composition in a .tsx file, like the example above, and import that file instead.

src/content/docs/example.mdx
---
title: Example
---
import BreadcrumbExample from "../../components/BreadcrumbExample";
<BreadcrumbExample client:load />

client:load hydrates the island on page load. Use client:visible for content far down the page.

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/BreadcrumbExample.astro
---
import BreadcrumbExample from "../BreadcrumbExample";
---
<BreadcrumbExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"breadcrumb-example": {
render: component("./src/components/markdoc/BreadcrumbExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% breadcrumb-example /%}

Parts of the component and the data-refineui role each one renders.

PartRole
rootbreadcrumb
ellipsisbreadcrumb-ellipsis
linkbreadcrumb-link
pagebreadcrumb-page

States the component styles. Component states are exposed as data attributes.

KindStates
Pseudofocus-visible