2020-08-13 15:18:26 +08:00
## Timeline
Visually display timeline.
### Basic usage
2020-11-19 15:46:20 +08:00
Timeline can be split into multiple activities. Timestamps are important features that distinguish them from other components. Note the difference with Steps.
2020-08-13 15:18:26 +08:00
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< div class = "block" >
2020-11-19 15:46:20 +08:00
< el-timeline >
2020-08-13 15:18:26 +08:00
< el-timeline-item
v-for="(activity, index) in activities"
:key="index"
2021-09-04 19:29:28 +08:00
:timestamp="activity.timestamp"
>
2020-08-13 15:18:26 +08:00
{{activity.content}}
< / el-timeline-item >
< / el-timeline >
< / div >
< script >
export default {
data() {
return {
2021-09-04 19:29:28 +08:00
activities: [
{
content: 'Event start',
timestamp: '2018-04-15',
},
{
content: 'Approved',
timestamp: '2018-04-13',
},
{
content: 'Success',
timestamp: '2018-04-11',
},
],
}
},
}
2020-08-13 15:18:26 +08:00
< / script >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Custom node
Size, color, and icons can be customized in node.
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< div class = "block" >
< el-timeline >
< el-timeline-item
v-for="(activity, index) in activities"
:key="index"
:icon="activity.icon"
:type="activity.type"
:color="activity.color"
:size="activity.size"
2021-09-05 11:07:24 +08:00
:hollow="activity.hollow"
2021-09-04 19:29:28 +08:00
:timestamp="activity.timestamp"
>
2020-08-13 15:18:26 +08:00
{{activity.content}}
< / el-timeline-item >
< / el-timeline >
< / div >
< script >
export default {
data() {
return {
2021-09-04 19:29:28 +08:00
activities: [
{
content: 'Custom icon',
timestamp: '2018-04-12 20:46',
size: 'large',
type: 'primary',
icon: 'el-icon-more',
},
{
content: 'Custom color',
timestamp: '2018-04-03 20:46',
color: '#0bbd87',
},
{
content: 'Custom size',
timestamp: '2018-04-03 20:46',
size: 'large',
},
2021-09-05 11:07:24 +08:00
{
content: 'Custom hollow',
timestamp: '2018-04-03 20:46',
type: 'primary',
hollow: true,
},
2021-09-04 19:29:28 +08:00
{
content: 'Default node',
timestamp: '2018-04-03 20:46',
},
],
}
},
}
2020-08-13 15:18:26 +08:00
< / script >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Custom timestamp
Timestamp can be placed on top of content when content is too high.
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< div class = "block" >
< el-timeline >
< el-timeline-item timestamp = "2018/4/12" placement = "top" >
< el-card >
< h4 > Update Github template< / h4 >
< p > Tom committed 2018/4/12 20:46< / p >
< / el-card >
< / el-timeline-item >
< el-timeline-item timestamp = "2018/4/3" placement = "top" >
< el-card >
< h4 > Update Github template< / h4 >
< p > Tom committed 2018/4/3 20:46< / p >
< / el-card >
< / el-timeline-item >
< el-timeline-item timestamp = "2018/4/2" placement = "top" >
< el-card >
< h4 > Update Github template< / h4 >
< p > Tom committed 2018/4/2 20:46< / p >
< / el-card >
< / el-timeline-item >
< / el-timeline >
< / div >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
2021-04-06 11:41:02 +08:00
### Timeline Slots
2021-09-04 19:29:28 +08:00
| Name | Description |
| ---- | --------------------------- |
| — | Custom content for timeline |
2021-04-06 11:41:02 +08:00
### Timeline-Item Attributes
2021-09-04 19:29:28 +08:00
| Attribute | Description | Type | Accepted Values | Default |
| -------------- | ------------------------- | ------- | ------------------------------------------- | ------- |
2021-09-05 11:07:24 +08:00
| timestamp | timestamp content | string | — | — |
2021-09-04 19:29:28 +08:00
| hide-timestamp | whether to show timestamp | boolean | — | false |
| placement | position of timestamp | string | top / bottom | bottom |
2021-09-05 11:07:24 +08:00
| type | node type | string | primary / success / warning / danger / info | — |
| color | background color of node | string | hsl / hsv / hex / rgb | — |
2021-09-04 19:29:28 +08:00
| size | node size | string | normal / large | normal |
2021-09-05 11:07:24 +08:00
| icon | icon class name | string | — | — |
| hollow | icon is hollow | boolean | — | false |
2020-08-13 15:18:26 +08:00
2021-04-06 11:41:02 +08:00
### Timeline-Item Slots
2021-09-04 19:29:28 +08:00
| Name | Description |
| ---- | -------------------------------- |
| — | Custom content for timeline item |
| dot | Custom defined node |