2020-08-13 11:47:56 +08:00
# Breadcrumb
:::tip
`Breadcrumb` can be used with embedded [`BreadcrumbItem` ](./breadcrumb-item ).
:::
## Demos
### Stylistic variants
2021-10-20 01:11:27 +08:00
Available style variants for the [`ui` ](#props-ui ) prop: `strong` .
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/breadcrumb/style.vue" ]]
### Size variants
2021-10-20 01:11:27 +08:00
Available size variants for the [`ui` ](#props-ui ) prop: `s` / `m` .
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/breadcrumb/size.vue" ]]
2021-10-26 16:40:44 +08:00
### Inline usage
2020-08-13 11:47:56 +08:00
Can be used with embedded `BreadcrumbItem` s.
[[ demo src="/demo/breadcrumb/base.vue" ]]
### Using datasource
2021-10-20 01:11:27 +08:00
Can be used with the [`routes` ](#props-routes ) prop as well.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/breadcrumb/datasource.vue" ]]
### Customizable separators
Separators can be customized.
[[ demo src="/demo/breadcrumb/separator.vue" ]]
### Events mode
2021-10-20 01:11:27 +08:00
Handling [`redirect` ](#events-redirect ) event instead of redirect with router.
2020-08-13 11:47:56 +08:00
[[ demo src="/demo/breadcrumb/redirect.vue" ]]
## API
### Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
2021-10-20 01:11:27 +08:00
| ``ui`` | `string=` | - | [^ui] |
| ``routes`` | `Array<Object>` | `[]` | [^routes] |
2020-08-13 11:47:56 +08:00
^^^ui
Style variants.
+++Enum values
| Value | Description |
| -- | -- |
| `s` | Small. |
| `m` | Medium. |
+++
^^^
^^^routes
2021-10-20 01:11:27 +08:00
The datasource for breadcrumb items. The type of items is `{label: string, type: string, to: string | Object=, native: boolean=}` . Properties apart from `label` can be referred to the props of [`BreadcrumbItem` ](./breadcrumb-item ) component.
2020-08-13 11:47:56 +08:00
:::warning
The last item will always be displayed as plain text by default.
:::
^^^
### Slots
| Name | Description |
| -- | -- |
2021-10-20 01:11:27 +08:00
| ``default`` | The items of the breadcrumb. Can only have [`BreadcrumbItem` ](./breadcrumb-item ) components as direct children. The [`routes` ](#props-routes ) prop will be ignored when this slot is specified. |
| ``item`` | [^slot-item] |
| ``separator`` | [^slot-separator] |
2020-08-13 11:47:56 +08:00
^^^slot-item
The content of each breadcrumb item. Default to the `label` properties of each item within `routes` , or the default slot content of [`BreadcrumbItem` ]('./breadcrumb-item ) components.
2022-01-24 18:53:52 +08:00
+++Slot props
2020-08-13 11:47:56 +08:00
| Name | Type | Description |
| -- | -- | -- |
2022-01-24 18:53:52 +08:00
| `route` | `Object` | The item in `routes` . Custom properties will also be passes into the slot props object. |
2020-08-13 11:47:56 +08:00
+++
^^^
^^^slot-separator
Separator between adjacent breadcrumb items. Displays a globally configured icon by default.
:::warning
When using Vue.js version `2.5.17` and below, it's required to bind a `slot-scope` .
:::
2021-10-29 17:13:10 +08:00
^^^
2020-08-13 11:47:56 +08:00
### Events
| Name | Description |
| -- | -- |
2021-10-20 01:11:27 +08:00
| ``redirect`` | [^redirect] |
2020-08-13 11:47:56 +08:00
^^^redirect
Triggered when clicking the item with `type` value `link` . The callback parameter list is `(event, route, index)` .
+++Parameters
| Name | Type | Description |
| -- | -- | -- |
| `event` | [Event ](https://developer.mozilla.org/en-US/docs/Web/Events/click ) | Native click event object. |
| `route` | `Object` | The corresponding route item in `routes` . |
| `index` | `number` | The index of the clicked item. |
+++
^^^