# Breadcrumb

Path trail with pixel chevron separators.

Source: https://www.ui95.dev/ui/breadcrumb

## Examples

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

import type { ShowcaseDemo } from "../types"

export const demo: ShowcaseDemo = {
  span: "wide",
  variants: [
    {
      label: "default",
      render: () => (
        <Breadcrumb>
          <BreadcrumbList>
            <BreadcrumbItem>
              <BreadcrumbLink href="#">Home</BreadcrumbLink>
            </BreadcrumbItem>
            <BreadcrumbSeparator />
            <BreadcrumbItem>
              <BreadcrumbLink href="#">Components</BreadcrumbLink>
            </BreadcrumbItem>
            <BreadcrumbSeparator />
            <BreadcrumbItem>
              <BreadcrumbPage>Breadcrumb</BreadcrumbPage>
            </BreadcrumbItem>
          </BreadcrumbList>
        </Breadcrumb>
      ),
    },
    {
      label: "ellipsis",
      render: () => (
        <Breadcrumb>
          <BreadcrumbList>
            <BreadcrumbItem>
              <BreadcrumbLink href="#">Home</BreadcrumbLink>
            </BreadcrumbItem>
            <BreadcrumbSeparator />
            <BreadcrumbItem>
              <BreadcrumbEllipsis />
            </BreadcrumbItem>
            <BreadcrumbSeparator />
            <BreadcrumbItem>
              <BreadcrumbPage>Current</BreadcrumbPage>
            </BreadcrumbItem>
          </BreadcrumbList>
        </Breadcrumb>
      ),
    },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/breadcrumb.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Dependencies:

```bash
npm install cn radix-ui
```

Add these items first:

- [pixel-glyphs](https://www.ui95.dev/ui/pixel-glyphs)

`components/ui/breadcrumb.tsx`

```tsx
import { cn } from "cn"
import { Slot } from "radix-ui"
import * as React from "react"

import { SlashGlyph } from "@/components/ui/pixel-glyphs"

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-2 font-pixel text-[12px] leading-none wrap-break-word text-muted-foreground uppercase",
        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({
  asChild,
  className,
  ...props
}: React.ComponentProps<"a"> & {
  asChild?: boolean
}) {
  const Comp = asChild ? Slot.Root : "a"

  return (
    <Comp
      data-slot="breadcrumb-link"
      className={cn("decoration-[length:var(--pixel)] underline-offset-4 hover:text-foreground hover:underline", className)}
      {...props}
    />
  )
}

function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
  return (
    <span
      data-slot="breadcrumb-page"
      role="link"
      aria-disabled="true"
      aria-current="page"
      className={cn("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", className)}
      {...props}
    >
      {children ?? (
        <SlashGlyph className="cn-rtl-flip" />
      )}
    </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",
        className
      )}
      {...props}
    >
      <svg
        viewBox="0 0 11 3"
        shapeRendering="crispEdges"
        fill="currentColor"
        aria-hidden="true"
        className="h-[9px] w-[33px]"
      >
        <rect x="0" y="0" width="3" height="3" />
        <rect x="4" y="0" width="3" height="3" />
        <rect x="8" y="0" width="3" height="3" />
      </svg>
      <span className="sr-only">More</span>
    </span>
  )
}

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

## API reference

### Breadcrumb

No props of its own. It forwards the props of the element or primitive it wraps.

### BreadcrumbEllipsis

No props of its own. It forwards the props of the element or primitive it wraps.

### BreadcrumbItem

No props of its own. It forwards the props of the element or primitive it wraps.

### BreadcrumbLink

| Prop | Type | Default |
| --- | --- | --- |
| `asChild` | `boolean` | - |

### BreadcrumbList

No props of its own. It forwards the props of the element or primitive it wraps.

### BreadcrumbPage

No props of its own. It forwards the props of the element or primitive it wraps.

### BreadcrumbSeparator

No props of its own. It forwards the props of the element or primitive it wraps.
