implement
Breadcrumb

Breadcrumb

The trail back up from where you are.

import {
	Breadcrumb,
	BreadcrumbEllipsis,
	BreadcrumbItem,
	BreadcrumbLink,
	BreadcrumbList,
	BreadcrumbPage,
	BreadcrumbSeparator,
} from "@/lib/components/ui/breadcrumb";

export default function BreadcrumbDemo() {
	return Breadcrumb(
		BreadcrumbList(
			BreadcrumbItem(BreadcrumbLink({ href: "/docs" }, "Docs")),
			BreadcrumbSeparator(),
			BreadcrumbItem(BreadcrumbEllipsis()),
			BreadcrumbSeparator(),
			BreadcrumbItem(BreadcrumbLink({ href: "/ui" }, "UI")),
			BreadcrumbSeparator(),
			BreadcrumbItem(BreadcrumbPage("Breadcrumb")),
		),
	);
}

Installation

npx jsrepo add @implementjs/ui/breadcrumb

It installs @implementjs/lucide at the same time.

Usage

import {
	Breadcrumb,
	BreadcrumbItem,
	BreadcrumbLink,
	BreadcrumbList,
	BreadcrumbPage,
	BreadcrumbSeparator,
} from "@/lib/components/ui/breadcrumb";

Breadcrumb(
	BreadcrumbList(
		BreadcrumbItem(BreadcrumbLink({ href: "/docs" }, "Docs")),
		BreadcrumbSeparator(),
		BreadcrumbItem(BreadcrumbPage("Breadcrumb")),
	),
);

The last crumb

The page you are on is a BreadcrumbPage, not a BreadcrumbLink — you do not link to where you already are. It carries aria-current="page", which is what tells a screen reader the trail has ended.

Separators

BreadcrumbSeparator is aria-hidden and presentational. The ordered list already says these are steps, so announcing "chevron right" between each pair would only be noise. Pass children to use a different mark:

BreadcrumbSeparator(SlashIcon());

Collapsing a long trail

BreadcrumbEllipsis stands in for levels you have dropped. On a deep tree, wrap it in a dropdown menu so the hidden levels are still reachable.

API Reference

The trail. Labelled "breadcrumb" for screen readers. Renders a Nav; extra props are forwarded onto it.

The ordered list of crumbs, wrapping on narrow screens. Renders a Ol; extra props are forwarded onto it.

One crumb. Renders a Li; extra props are forwarded onto it.

A crumb that navigates. Renders a A; extra props are forwarded onto it.

The crumb for the page you are on: not a link, and marked aria-current="page". Renders a Span; extra props are forwarded onto it.

The mark between crumbs — a chevron unless you pass your own. Presentational and aria-hidden: the list already says these are steps. Renders a Li; extra props are forwarded onto it.

Stands in for crumbs that have been collapsed away. Renders a Span; extra props are forwarded onto it.