Skip to contentVibraUI
Navigation & layout

Breadcrumb

The trail from the top of the app to the current page.

shadcn's base-nova breadcrumb with three changes: a link's colour change is timed on the theme's motion tokens (--duration-fast, --ease-standard), so it stops with everything else under reduced motion; a link takes the kit's focus ring, where shadcn's leaves the browser's own; and the default chevron turns in a right-to-left trail, so it points the way the trail reads. The current page is marked aria-current="page".

Install

npx shadcn@latest add @vibra/breadcrumb

Needs the @vibra registry in your components.json — set it up once.

Examples

Collapsed into a menu

A deep path keeps its ends and folds the folders between into a menu that says how many it hides.

Custom separator

The separator's children replace the chevron, and a crumb can be an icon so long as it keeps a name.

Above a page title

Over a record's title; on a phone it shortens to the one step back.

With a switcher

Beside the page crumb, a button to go sideways to a sibling without climbing the trail.

Right to left

The demo's trail in Arabic: it runs from the right, and the chevrons turn to point the way it reads.

Props

PropTypeDefaultDescription
BreadcrumbLink.renderReact.ReactElement—Renders the link as your router's link — next/link, say — keeping its look.

Dependencies

Source

components/ui/breadcrumb.tsx
import * as React from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "@/lib/utils"
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"

function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
  return (
    <nav
      aria-label="breadcrumb"
      data-slot="breadcrumb"
      className={cn(className)}
      {...props}
    />
  )
}

function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
  return (
    <ol
      data-slot="breadcrumb-list"
      className={cn(
        "flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",
        className
      )}
      {...props}
    />
  )
}

function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
  return (
    <li
      data-slot="breadcrumb-item"
      className={cn("inline-flex items-center gap-1", className)}
      {...props}
    />
  )
}

function BreadcrumbLink({
  className,
  render,
  ...props
}: useRender.ComponentProps<"a">) {
  return useRender({
    defaultTagName: "a",
    props: mergeProps<"a">(
      {
        // The kit's one focus treatment: without it a link fell back to the
        // browser's thin ring in the accent at half strength.
        className: cn(
          "rounded-sm transition-colors duration-(--duration-fast) ease-(--ease-standard) focus-ring hover:text-foreground",
          className
        ),
      },
      props
    ),
    render,
    state: {
      slot: "breadcrumb-link",
    },
  })
}

function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
  return (
    <span
      data-slot="breadcrumb-page"
      role="link"
      aria-disabled="true"
      aria-current="page"
      className={cn("font-normal text-foreground", className)}
      {...props}
    />
  )
}

function BreadcrumbSeparator({
  children,
  className,
  ...props
}: React.ComponentProps<"li">) {
  return (
    <li
      data-slot="breadcrumb-separator"
      role="presentation"
      aria-hidden="true"
      className={cn("[&>svg]:size-3.5", className)}
      {...props}
    >
      {/* Points the way the trail reads, in either direction. */}
      {children ?? <ChevronRightIcon className="rtl:rotate-180" />}
    </li>
  )
}

function BreadcrumbEllipsis({
  className,
  ...props
}: React.ComponentProps<"span">) {
  return (
    <span
      data-slot="breadcrumb-ellipsis"
      role="presentation"
      aria-hidden="true"
      className={cn(
        "flex size-5 items-center justify-center [&>svg]:size-4",
        className
      )}
      {...props}
    >
      <MoreHorizontalIcon
      />
      <span className="sr-only">More</span>
    </span>
  )
}

export {
  Breadcrumb,
  BreadcrumbList,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbPage,
  BreadcrumbSeparator,
  BreadcrumbEllipsis,
}