

<InteractiveDemo
  name="breadcrumbs"
  controls="[
  {
    type: 'boolean',
    name: 'isDisabled',
    defaultValue: false,
  },
]"
/>

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/breadcrumbs
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/breadcrumbs
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/breadcrumbs
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun x shadcn@latest add @dotui/breadcrumbs
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

Use breadcrumbs to display a hierarchy of links showing the user's location in a site or application.

```tsx
import {
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbSeparator,
  Breadcrumbs,
} from '@/components/ui/breadcrumbs'
```

```tsx
<Breadcrumbs>
  <BreadcrumbItem>
    <BreadcrumbLink href="#">Home</BreadcrumbLink>
    <BreadcrumbSeparator />
  </BreadcrumbItem>
  <BreadcrumbItem>
    <BreadcrumbLink href="#">Components</BreadcrumbLink>
    <BreadcrumbSeparator />
  </BreadcrumbItem>
  <BreadcrumbItem>
    <BreadcrumbLink>Breadcrumbs</BreadcrumbLink>
  </BreadcrumbItem>
</Breadcrumbs>
```

## Framework Setup [#framework-setup]

By default, `BreadcrumbLink` renders a plain `<a>` tag. To integrate with your framework's router, override the component in your project's `breadcrumbs.tsx`.

### Next.js [#nextjs]

```tsx title="ui/breadcrumbs.tsx"
import RouterLink from "next/link"; // [!code highlight]

// ..

const BreadcrumbLink = ({ className, ...props }: BreadcrumbLinkProps) => {
  return (
    <AriaLink
      // [!code highlight:11]
      render={({ ref, href, ...domProps }) => {
        "href" in domProps ? (
          <RouterLink
            ref={ref as React.Ref<HTMLAnchorElement>}
            href={href}
            {...domProps}
          />
        ) : (
          <span ref={ref as React.Ref<HTMLSpanElement>} {...domProps} />
        )
      }
      className={composeRenderProps(className, (className) =>
        link({ className }),
      )}
      {...props}
    />
  );
};
```

### TanStack Start [#tanstack-start]

```tsx title="ui/breadcrumbs.tsx"
// [!code highlight:2]
import { Link as RouterLink } from '@tanstack/react-router'
import type { ToOptions } from '@tanstack/react-router'

// ..

interface BreadcrumbLinkProps extends Omit<
  React.ComponentProps<typeof AriaLink>,
  'href'
> {
  href?: string | ToOptions // [!code highlight]
}
const BreadcrumbLink = ({ className, ...props }: BreadcrumbLinkProps) => {
  return (
    <AriaLink
      // [!code highlight:10]
      href={typeof href === 'object' ? href.to : href}
      render={({ ref, ...domProps }) => {
        if (typeof href === 'object') {
          return (
            <RouterLink
              ref={ref as React.Ref<HTMLAnchorElement>}
              {...href}
              {...domProps}
            />
          )
        }
        if (typeof href === 'string') {
          return (
            <a
              ref={ref as React.Ref<HTMLAnchorElement>}
              href={href}
              {...domProps}
            />
          )
        }
        return <span ref={ref} {...domProps} />
      }}
      className={composeRenderProps(className, (className) =>
        link({ className }),
      )}
      {...props}
    />
  )
}
```

## Examples [#examples]

<Examples className="sm:grid-cols-2">
  <Example title="With Menu" name="breadcrumbs/demos/menu" />

  <Example title="Custom Separator" name="breadcrumbs/demos/custom-separator" />
</Examples>

## API Reference [#api-reference]

### Breadcrumbs [#breadcrumbs]

<Reference name="breadcrumbs" />

### BreadcrumbItem [#breadcrumbitem]

<Reference name="breadcrumb-item" />

### BreadcrumbLink [#breadcrumblink]

<Reference name="breadcrumb-link" />

### BreadcrumbSeparator [#breadcrumbseparator]

<Reference name="breadcrumb-separator" />
