Breadcrumbs

Where a page sits in its tree, with each step a link and a long trail folded.

Five levels deep: the middle folds into “…”.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/breadcrumbs

Usage

import { Breadcrumbs } from "./ui/uicontext/components/kit/Breadcrumbs.ts"
const Message = UiSchema.TaggedEnum({ OpenedPage: { id: Schema.String } })export const PageTrail = (h: Html.H<typeof Message.Type>) =>	Breadcrumbs(h, {		props: {			trail: [				{ id: "handbook", label: "Handbook", icon: "📘" },				{ id: "onboarding", label: "Onboarding" },				{ id: "first-week", label: "Your first week" },			],		},		onEmit: { RequestedOpen: ({ id }) => Message.OpenedPage({ id }) },	})

Examples

Give a step an href and it renders as a link, so people can open it in a new tab.

More steps before folding

A wide page can show more of the trail: here the first step and the last three stay visible.

API reference

Props

Breadcrumbs props
NameTypeDescription
trailrequiredBreadcrumbStep[]The steps from the top to the current page, which is last
labelstringThe landmark's name: "Breadcrumb"
maxnumberThe most steps shown before the middle folds into "…" (4)

Events

Breadcrumbs events
EventPayloadDescription
RequestedOpen{ id: string }A step without a link, or a folded one, was chosen

Accessibility

  • A nav landmark named Breadcrumb holding an ordered list; the page itself is aria-current="page".
  • Folded steps sit in a menu button that names how many it holds.

Source