Back to Shadcn Ui

Breadcrumb

apps/v4/content/docs/components/radix/breadcrumb.mdx

latest4.0 KB
Original Source

<ComponentPreview styleName="radix-nova" name="breadcrumb-demo" previewClassName="p-2" />

Installation

<CodeTabs> <TabsList> <TabsTrigger value="cli">Command</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
bash
npx shadcn@latest add breadcrumb
</TabsContent> <TabsContent value="manual"> <Steps className="mb-0 pt-2">

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="breadcrumb" title="components/ui/breadcrumb.tsx" />

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </CodeTabs>

Usage

tsx
import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator,
} from "@/components/ui/breadcrumb"
tsx
<Breadcrumb>
  <BreadcrumbList>
    <BreadcrumbItem>
      <BreadcrumbLink href="/">Home</BreadcrumbLink>
    </BreadcrumbItem>
    <BreadcrumbSeparator />
    <BreadcrumbItem>
      <BreadcrumbLink href="/components">Components</BreadcrumbLink>
    </BreadcrumbItem>
    <BreadcrumbSeparator />
    <BreadcrumbItem>
      <BreadcrumbPage>Breadcrumb</BreadcrumbPage>
    </BreadcrumbItem>
  </BreadcrumbList>
</Breadcrumb>

Examples

Basic

A basic breadcrumb with a home link and a components link.

<ComponentPreview styleName="radix-nova" name="breadcrumb-basic" />

Custom separator

Use a custom component as children for <BreadcrumbSeparator /> to create a custom separator.

<ComponentPreview styleName="radix-nova" name="breadcrumb-separator" />

You can compose <BreadcrumbItem /> with a <DropdownMenu /> to create a dropdown in the breadcrumb.

<ComponentPreview styleName="radix-nova" name="breadcrumb-dropdown" />

Collapsed

We provide a <BreadcrumbEllipsis /> component to show a collapsed state when the breadcrumb is too long.

<ComponentPreview styleName="radix-nova" name="breadcrumb-ellipsis" previewClassName="p-2" />

To use a custom link component from your routing library, you can use the asChild prop on <BreadcrumbLink />.

<ComponentPreview styleName="radix-nova" name="breadcrumb-link" />

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

<ComponentPreview styleName="radix-nova" name="breadcrumb-rtl" direction="rtl" previewClassName="p-2" />

API Reference

The Breadcrumb component is the root navigation element that wraps all breadcrumb components.

PropTypeDefault
classNamestring-

The BreadcrumbList component displays the ordered list of breadcrumb items.

PropTypeDefault
classNamestring-

The BreadcrumbItem component wraps individual breadcrumb items.

PropTypeDefault
classNamestring-

The BreadcrumbLink component displays a clickable link in the breadcrumb.

PropTypeDefault
classNamestring-

The BreadcrumbPage component displays the current page in the breadcrumb (non-clickable).

PropTypeDefault
classNamestring-

The BreadcrumbSeparator component displays a separator between breadcrumb items. You can pass custom children to override the default separator icon.

PropTypeDefault
childrenReact.ReactNode-
classNamestring-

The BreadcrumbEllipsis component displays an ellipsis indicator for collapsed breadcrumb items.

PropTypeDefault
classNamestring-