Breadcrumbs
Plain, calm breadcrumbs. The slashes sway like blades of grass and lean toward your pointer as it moves along the trail.
Installation
pnpm dlx shadcn@latest add @breeze/breadcrumbsUsage
import { Breadcrumbs } from "@/components/breeze/breadcrumbs"Pass the trail with the current page last:
<Breadcrumbs
items={[
{ label: "Home", href: "/" },
{ label: "Docs", href: "/docs" },
{ label: "Breadcrumbs" },
]}
/>Or the shorthand, which builds the links from the segments:
<Breadcrumbs path="Home/Docs/Components/Breadcrumbs" />The slashes
Everything stays quiet: muted words, the current page a step stronger, thin slashes between them. The one bit of play is the slashes. At rest they sway, barely, each at its own pace. Move your pointer along the trail and the ones nearby lean toward it, the closest most, then spring softly back upright when you leave. lean sets how far they bend, and sway={false} keeps them still at rest.
When the trail changes, new pages fade in with a little drift and the ones you leave fade away. Past maxItems, the middle collapses into a plain "…" you can click to show the full path. With reduced motion the slashes stay still.
With your router
Pass your link component as linkAs, for example Next's Link, or handle clicks yourself with onNavigate, which receives the href and position:
import Link from "next/link"
<Breadcrumbs items={items} linkAs={Link} />
<Breadcrumbs items={items} onNavigate={(href) => router.push(href)} />With state
The preview above is a small file browser: keep the trail in state, open a folder to push onto it, and trim it in onNavigate to go back.
"use client"
import { useState } from "react"
import { Breadcrumbs } from "@/components/breeze/breadcrumbs"
export function FileBrowser() {
const [trail, setTrail] = useState(["Home", "Projects", "Breeze"])
return (
<Breadcrumbs
items={trail.map((label, i) => ({
label,
href: "/" + trail.slice(0, i + 1).join("/"),
}))}
onNavigate={(_, index) => setTrail((t) => t.slice(0, index + 1))}
/>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | { label: ReactNode; href?: string }[] | The trail, current page last | |
path | string | Shorthand, e.g. "Home/Docs/Components" | |
maxItems | number | 5 | Most items before the middle collapses into "…" |
lean | number | 22 | How far the slashes lean toward the pointer, in degrees |
sway | boolean | true | The slashes sway gently at rest |
onNavigate | (href: string, index: number) => void | Handle clicks instead of following links | |
linkAs | ElementType | "a" | Link component, e.g. Next's Link |
It renders <nav aria-label="Breadcrumb"> with an ordered list, and the current page is marked aria-current="page".