组件

Breadcrumb

The path to the page you are on, written in a notebook: names between pencil slashes, links that wear the highlighter when pointed at, and the current page underlined twice in blue felt. Swap the slash for a chevron or any node, and fold the middle of a long path into a dropdown.

安装

terminal
npx shadcn@latest add @wobko/breadcrumb

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Default

Home, Components, and the page you are on. Point at Components: links wear the highlighter. The current page is bold and underlined twice in blue felt.

Folded path with a menu

The middle of a long path folded into an ellipsis that opens a dropdown of the hidden crumbs (the ellipsis is the trigger, so it is a real button with a name).

Separators

A pencil slash is the default. Children replace it: a drawn chevron, an arrow, a dot. Links can also be your router's element with asChild.

File path (composed)

A real use: the crumbs are the folders you have opened. Click one to go back up; when the path is longer than four names the middle folds into an ellipsis whose menu takes you there too.

A crumb that opens a menu

Any crumb can be a DropdownMenuTrigger: here the middle name is a button with a little chevron, and its menu lists the sibling pages. It wears the highlighter while it is open, like a link does when you point at it.

Collapsed, with no menu

The shadcn demo of BreadcrumbEllipsis: three pencil dots stand in for the middle of a long path. On its own it is only decoration, hidden from screen readers; wrapped in a link or button it needs an aria-label, and then it can lead to the full list.

With your router's Link

BreadcrumbLink asChild hands the highlighter, spacing and focus ring to whatever element you give it. Here that is a Link that changes the path without loading a page (a stand-in for next/link, React Router or TanStack Router); the trail is built from the path.

Responsive: menu or drawer

A deep path keeps its first and last two crumbs and folds the rest. The fold opens a dropdown on a wide screen and a drawer on a phone, from one component: the query is read with useSyncExternalStore, so the server renders the wide version and a phone swaps after hydration.

API 参考

BreadcrumbLink

A link on the path (an `a`, or your router link with `asChild`). Pointed at or keyboard-focused it wears the highlighter.

属性类型默认值说明
asChildbooleanfalseRender your element (Next's Link, a router NavLink).

BreadcrumbPage

The page you are on: bold, `aria-current="page"`, underlined twice in blue felt (one pencil line in calm density). The underline is the only drawing in a breadcrumb; it becomes an ink host once it is measured.

属性类型默认值说明
seedstring | number-Pins the hand. Default: derived from useId().

无障碍

  • Landmark and list semantics as in the WAI-ARIA breadcrumb pattern: `nav` labeled "breadcrumb" holding an ordered list; the current page carries `aria-current="page"` (and, as upstream, `role="link"` with `aria-disabled` since it goes nowhere).
  • Separators and the ellipsis glyph are hidden from assistive technology; the ellipsis keeps an `sr-only` "More", and the button you wrap it in needs its own name ("Toggle menu").
  • The underline and the highlighter are decoration with no pointer events and never move the text. Links keep the theme's focus ring; the current page is bold and underlined, so it does not depend on color.

源码

CLI 会复制进你项目的文件。

正在加载源码