Breadcrumb
Displays the path to the current resource using a hierarchy of links.
- next pagenext pagenext page
Installation
yarn add @camped-ui/breadcrumb
Usage
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@camped-ui/breadcrumb"
<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
Custom separator
Use a custom component as children
for <BreadcrumbSeparator />
to create a custom separator.
- next pagenext page
import { SlashIcon } from "@radix-ui/react-icons"
...
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">Home</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<SlashIcon />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbLink href="/components">Components</BreadcrumbLink>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
Variants
By default, the Breadcrumb component uses the default variant for each item. You can change the variant by passing the variant prop to the BreadcrumbItem component.
Orientation
Use the orientation
prop to set the orientation of the breadcrumb.
BreadCrumb Active Item
You can indicate the active item by passing the isActive prop to the BreadcrumbItem component.
Dropdown
You can compose <BreadcrumbItem />
with a <DropdownMenu />
to create a dropdown in the breadcrumb.
- next pagenext page
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@camped-ui/dropdown-menu"
...
<BreadcrumbItem>
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center gap-1">
Components
<ChevronDownIcon />
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Documentation</DropdownMenuItem>
<DropdownMenuItem>Themes</DropdownMenuItem>
<DropdownMenuItem>GitHub</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</BreadcrumbItem>
Collapsed
We provide a <BreadcrumbEllipsis />
component to show a collapsed state when the breadcrumb is too long.
- next page
import { BreadcrumbEllipsis } from "@camped-ui/breadcrumb"
...
<Breadcrumb>
<BreadcrumbList>
{/* ... */}
<BreadcrumbItem>
<BreadcrumbEllipsis />
</BreadcrumbItem>
{/* ... */}
</BreadcrumbList>
</Breadcrumb>
Link component
To use a custom link component from your routing library, you can use the asChild
prop on <BreadcrumbLink />
.
- next pagenext page
import { Link } from "next/link"
...
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link href="/">Home</Link>
</BreadcrumbLink>
</BreadcrumbItem>
{/* ... */}
</BreadcrumbList>
</Breadcrumb>
Responsive
Here's an example of a responsive breadcrumb that composes <BreadcrumbItem />
with <BreadcrumbEllipsis />
, <DropdownMenu />
, and <Drawer />
.
It displays a dropdown on desktop and a drawer on mobile.
- next pagenext page