2016-06-19 11:14:21 +08:00
---
category: Components
type: Navigation
title: Breadcrumb
2020-05-31 11:48:34 +08:00
cover: https://gw.alipayobjects.com/zos/alicdn/9Ltop8JwH/Breadcrumb.svg
2016-06-19 11:14:21 +08:00
---
2016-11-29 17:13:24 +08:00
A breadcrumb displays the current location within a hierarchy. It allows going back to states higher up in the hierarchy.
2016-06-19 11:14:21 +08:00
2016-09-10 13:43:30 +08:00
## When To Use
2016-06-19 11:14:21 +08:00
- When the system has more than two layers in a hierarchy.
- When you need to inform the user of where they are.
2016-11-29 17:13:24 +08:00
- When the user may need to navigate back to a higher level.
2016-06-19 11:14:21 +08:00
2022-10-23 00:33:45 +08:00
### Usage upgrade after 4.24.0
```__react
import Alert from '../alert';
2022-10-30 17:17:47 +08:00
ReactDOM.render(< Alert message = "After version 4.24.0, we provide a simpler usage <Breadcrumb.Item menu={{ items: [...] }}> with better performance and potential of writing simpler code style in your applications. Meanwhile, we deprecated the old usage in browser console, we will remove it in antd 5.0." / > , mountNode);
2022-10-23 00:33:45 +08:00
```
```jsx
// works when >=4.24.0, recommended ✅
const items = [
{ label: 'item 1', key: 'item-1' }, // remember to pass the key prop
{ label: 'item 2', key: 'item-2' },
];
return (
< Breadcrumb >
< Breadcrumb.Item menu = {{ items } } > Ant Design< / Breadcrumb.Item >
< / Breadcrumb >
);
// works when < 4.24.0 , deprecated when > =4.24.0 🙅🏻♀️
const menu = (
< Menu >
< Menu.Item > item 1< / Menu.Item >
< Menu.Item > item 2< / Menu.Item >
< / Menu >
);
return (
< Breadcrumb >
< Breadcrumb.Item overlay = {menu} > Ant Design< / Breadcrumb.Item >
< / Breadcrumb >
);
```
2016-06-19 11:14:21 +08:00
## API
2019-11-20 18:10:44 +08:00
### Breadcrumb
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| itemRender | Custom item renderer | (route, params, routes, paths) => ReactNode | - | |
| params | Routing parameters | object | - | |
| routes | The routing stack information of router | [routes\[\]](#routes) | - | |
2020-10-09 10:08:52 +08:00
| separator | Custom separator | ReactNode | `/` | |
2019-11-20 18:10:44 +08:00
### Breadcrumb.Item
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2020-12-09 09:54:44 +08:00
| className | The additional css class | string | - | |
2020-08-05 14:50:52 +08:00
| dropdownProps | The dropdown props | [Dropdown ](/components/dropdown ) | - | |
2019-11-20 18:10:44 +08:00
| href | Target of hyperlink | string | - | |
2022-10-23 00:33:45 +08:00
| menu | The menu props | [MenuProps ](/components/menu/#API ) | - | 4.24.0 |
2020-10-21 10:33:43 +08:00
| onClick | Set the handler to handle click event | (e:MouseEvent) => void | - | |
2019-11-20 18:10:44 +08:00
### Breadcrumb.Separator
2022-10-23 00:33:45 +08:00
| Property | Description | Type | Default | Version |
| -------- | ---------------- | --------- | ------- | ------- |
| children | Custom separator | ReactNode | `/` | |
2019-11-20 18:10:44 +08:00
> When using `Breadcrumb.Separator`,its parent component must be set to `separator=""`, otherwise the default separator of the parent component will appear.
### routes
```ts
interface Route {
path: string;
breadcrumbName: string;
children: Array< {
path: string;
breadcrumbName: string;
}>;
}
```
2016-08-29 16:52:35 +08:00
2016-12-04 15:17:17 +08:00
### Use with browserHistory
2017-09-08 09:43:43 +08:00
The link of Breadcrumb item targets `#` by default, you can use `itemRender` to make a `browserHistory` Link.
2016-12-04 15:17:17 +08:00
```jsx
import { Link } from 'react-router';
2019-05-06 12:04:39 +08:00
const routes = [
{
path: 'index',
breadcrumbName: 'home',
},
{
path: 'first',
breadcrumbName: 'first',
children: [
{
path: '/general',
breadcrumbName: 'General',
},
{
path: '/layout',
breadcrumbName: 'Layout',
},
{
path: '/navigation',
breadcrumbName: 'Navigation',
},
],
},
{
path: 'second',
breadcrumbName: 'second',
},
];
2016-12-04 15:17:17 +08:00
function itemRender(route, params, routes, paths) {
const last = routes.indexOf(route) === routes.length - 1;
2019-05-06 12:04:39 +08:00
return last ? (
< span > {route.breadcrumbName}< / span >
) : (
< Link to = {paths.join('/')} > {route.breadcrumbName}< / Link >
);
2016-12-04 15:17:17 +08:00
}
2017-10-19 22:36:49 +08:00
return < Breadcrumb itemRender = {itemRender} routes = {routes} / > ;
2016-12-04 15:17:17 +08:00
```