mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-23 12:45:47 +00:00
* feat: rtl * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add sidebar * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * chore: changeset * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix
188 lines
4.2 KiB
Plaintext
188 lines
4.2 KiB
Plaintext
---
|
|
title: Breadcrumb
|
|
description: Displays the path to the current resource using a hierarchy of links.
|
|
base: base
|
|
component: true
|
|
---
|
|
|
|
<ComponentPreview
|
|
styleName="base-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"
|
|
styleName="base-nova"
|
|
/>
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</CodeTabs>
|
|
|
|
## Usage
|
|
|
|
```tsx showLineNumbers
|
|
import {
|
|
Breadcrumb,
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
} from "@/components/ui/breadcrumb"
|
|
```
|
|
|
|
```tsx showLineNumbers
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink render={<a href="/" />}>Home</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink render={<a 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="base-nova" name="breadcrumb-basic" />
|
|
|
|
### Custom separator
|
|
|
|
Use a custom component as `children` for `<BreadcrumbSeparator />` to create a custom separator.
|
|
|
|
<ComponentPreview styleName="base-nova" name="breadcrumb-separator" />
|
|
|
|
### Dropdown
|
|
|
|
You can compose `<BreadcrumbItem />` with a `<DropdownMenu />` to create a dropdown in the breadcrumb.
|
|
|
|
<ComponentPreview styleName="base-nova" name="breadcrumb-dropdown" />
|
|
|
|
### Collapsed
|
|
|
|
We provide a `<BreadcrumbEllipsis />` component to show a collapsed state when the breadcrumb is too long.
|
|
|
|
<ComponentPreview
|
|
styleName="base-nova"
|
|
name="breadcrumb-ellipsis"
|
|
previewClassName="p-2"
|
|
/>
|
|
|
|
### Link component
|
|
|
|
To use a custom link component from your routing library, you can use the `render` prop on `<BreadcrumbLink />`.
|
|
|
|
<ComponentPreview styleName="base-nova" name="breadcrumb-link" />
|
|
|
|
## RTL
|
|
|
|
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
|
|
|
|
<ComponentPreview
|
|
styleName="base-nova"
|
|
name="breadcrumb-rtl"
|
|
direction="rtl"
|
|
previewClassName="p-2"
|
|
/>
|
|
|
|
## API Reference
|
|
|
|
### Breadcrumb
|
|
|
|
The `Breadcrumb` component is the root navigation element that wraps all breadcrumb components.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbList
|
|
|
|
The `BreadcrumbList` component displays the ordered list of breadcrumb items.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbItem
|
|
|
|
The `BreadcrumbItem` component wraps individual breadcrumb items.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbLink
|
|
|
|
The `BreadcrumbLink` component displays a clickable link in the breadcrumb.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbPage
|
|
|
|
The `BreadcrumbPage` component displays the current page in the breadcrumb (non-clickable).
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbSeparator
|
|
|
|
The `BreadcrumbSeparator` component displays a separator between breadcrumb items. You can pass custom children to override the default separator icon.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | ----------------- | ------- |
|
|
| `children` | `React.ReactNode` | - |
|
|
| `className` | `string` | - |
|
|
|
|
### BreadcrumbEllipsis
|
|
|
|
The `BreadcrumbEllipsis` component displays an ellipsis indicator for collapsed breadcrumb items.
|
|
|
|
| Prop | Type | Default |
|
|
| ----------- | -------- | ------- |
|
|
| `className` | `string` | - |
|