Timeline
Display a sequence of records vertically in chronological order, such as operation logs, delivery progress, or project milestones. Each record uses HuiTimelineItem.
Import
import { HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
Basic usage
The default slot of HuiTimelineItem contains its content. timestamp provides the time text, displayed below the content.
<script setup lang="ts">
import { HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
</script>
<template>
<HuiTimeline>
<HuiTimelineItem timestamp="2026-01-05">Project kickoff</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-02-10">Design completed</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-04-20">Development completed</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-05-08">Released</HuiTimelineItem>
</HuiTimeline>
</template>
Reverse order
When reverse is true, the last item appears at the top. Only the display order changes; the data order stays the same.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiSwitch, HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
const reverse = ref(true)
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSwitch v-model="reverse" active-text="Newest first (reverse)" />
<HuiTimeline :reverse="reverse">
<HuiTimelineItem timestamp="2026-01-05">Project kickoff</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-02-10">Design completed</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-04-20">Development completed</HuiTimelineItem>
</HuiTimeline>
</HuiSpace>
</template>
Node types
type determines the node color and accepts primary (default), success, warning, danger, and info.
<template>
<HuiTimeline>
<HuiTimelineItem type="primary" timestamp="type=primary">In progress</HuiTimelineItem>
<HuiTimelineItem type="success" timestamp="type=success">Completed</HuiTimelineItem>
<HuiTimelineItem type="warning" timestamp="type=warning">At risk</HuiTimelineItem>
<HuiTimelineItem type="danger" timestamp="type=danger">Failed</HuiTimelineItem>
<HuiTimelineItem type="info" timestamp="type=info">Not started</HuiTimelineItem>
</HuiTimeline>
</template>
Node size and hollow nodes
size accepts normal (default, 12px) and large (16px). hollow draws a hollow circle whose border follows type. Both options work together and with any type.
The left side shows all four size/hollow combinations; the right side shows large hollow nodes for each type:
<template>
<HuiSpace wrap align="start" :size="48">
<HuiTimeline>
<HuiTimelineItem timestamp="size=normal">Normal node</HuiTimelineItem>
<HuiTimelineItem size="large" timestamp="size=large">Large node</HuiTimelineItem>
<HuiTimelineItem hollow timestamp="hollow">Hollow node</HuiTimelineItem>
<HuiTimelineItem hollow size="large" timestamp="hollow + size=large">
Large hollow node
</HuiTimelineItem>
</HuiTimeline>
<HuiTimeline>
<HuiTimelineItem hollow size="large" type="primary">primary</HuiTimelineItem>
<HuiTimelineItem hollow size="large" type="success">success</HuiTimelineItem>
<HuiTimelineItem hollow size="large" type="warning">warning</HuiTimelineItem>
<HuiTimelineItem hollow size="large" type="danger">danger</HuiTimelineItem>
<HuiTimelineItem hollow size="large" type="info">info</HuiTimelineItem>
</HuiTimeline>
</HuiSpace>
</template>
Custom colors
color accepts any CSS color and takes precedence over type. It colors the background of solid nodes and the border of hollow nodes.
<template>
<HuiTimeline>
<HuiTimelineItem color="#52c41a" timestamp="2026-01-05">Solid node</HuiTimelineItem>
<HuiTimelineItem color="#f5222d" hollow timestamp="2026-01-06">Hollow node</HuiTimelineItem>
<HuiTimelineItem color="#722ed1" size="large" timestamp="2026-01-07"
>Large node</HuiTimelineItem
>
<HuiTimelineItem color="var(--hui-color-warning)" timestamp="2026-01-08">
Theme variables also work
</HuiTimelineItem>
</HuiTimeline>
</template>
Custom nodes
Use the dot slot to replace the dot with an icon or other content. The default dot is omitted. Slot content is centered on the connecting line, with its color inherited from type or set through color.
<script setup lang="ts">
import { HuiTimeline, HuiTimelineItem, HuiIcon } from '@nscode/handy-ui'
</script>
<template>
<HuiTimeline>
<HuiTimelineItem timestamp="2026-03-01 09:12">
<template #dot><HuiIcon name="user" size="md" /></template>
Zhang Wei submitted a release request
</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-03-01 10:30" type="success">
<template #dot><HuiIcon name="success" size="md" /></template>
Approved
</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-03-01 11:05" type="danger">
<template #dot><HuiIcon name="error" size="md" /></template>
Release failed
</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-03-01 11:20" color="#722ed1">
<template #dot><HuiIcon name="clock" size="md" /></template>
Waiting to retry
</HuiTimelineItem>
</HuiTimeline>
</template>
Timestamp placement
placement sets whether the timestamp is above or below the content: bottom (default) or top. Put it above when time is more prominent than the content, such as in an operation log.
<template>
<HuiSpace wrap align="start" :size="48">
<div>
<p class="demo-label">placement="bottom"</p>
<HuiTimeline>
<HuiTimelineItem timestamp="2026-01-05">Project kickoff</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-02-10">Design completed</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-04-20">Development completed</HuiTimelineItem>
</HuiTimeline>
</div>
<div>
<p class="demo-label">placement="top"</p>
<HuiTimeline>
<HuiTimelineItem timestamp="2026-01-05" placement="top">Project kickoff</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-02-10" placement="top">Design completed</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-04-20" placement="top"
>Development completed</HuiTimelineItem
>
</HuiTimeline>
</div>
</HuiSpace>
</template>
<style scoped>
.demo-label {
margin: 0 0 12px;
color: var(--hui-text-color-secondary);
font-size: var(--hui-font-size-sm);
}
</style>
Hiding timestamps
No timestamp is displayed when timestamp is omitted. Use hide-timestamp to temporarily hide a provided timestamp.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSpace, HuiSwitch, HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
const hide = ref(true)
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSwitch v-model="hide" active-text="Hide the first timestamp (hide-timestamp)" />
<HuiTimeline>
<HuiTimelineItem timestamp="2026-01-05" :hide-timestamp="hide"
>Project kickoff</HuiTimelineItem
>
<HuiTimelineItem>No timestamp provided</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-04-20">Timestamp displayed normally</HuiTimelineItem>
</HuiTimeline>
</HuiSpace>
</template>
Rich content
The content area accepts any elements and components. The connecting line grows with the content height.
<script setup lang="ts">
import { HuiButton, HuiTag, HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
</script>
<template>
<HuiTimeline>
<HuiTimelineItem timestamp="2026-05-08 10:30" placement="top" type="success">
<h4 style="margin: 0 0 4px">Delivered</h4>
<p style="margin: 0; color: var(--hui-text-color-secondary)">
Your parcel has been signed for. Thank you.
</p>
</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-05-08 08:15" placement="top">
<h4 style="margin: 0 0 4px">
Out for delivery
<HuiTag size="small" type="warning">Arriving today</HuiTag>
</h4>
<p style="margin: 0 0 8px; color: var(--hui-text-color-secondary)">
Courier Wang is delivering your parcel. Phone: 138 0000 1234
</p>
<HuiButton size="small" icon="phone">Contact courier</HuiButton>
</HuiTimelineItem>
<HuiTimelineItem timestamp="2026-05-07 21:40" placement="top" type="info">
<h4 style="margin: 0 0 4px">In transit</h4>
<p style="margin: 0; color: var(--hui-text-color-secondary)">
Arrived at the Hangzhou sorting center
</p>
</HuiTimelineItem>
</HuiTimeline>
</template>
Rendering data
Records usually come from an array rendered with v-for. Click Add record to append one. Enable the switch to display the newest record at the top.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiSwitch, HuiTimeline, HuiTimelineItem } from '@nscode/handy-ui'
import type { TimelineItemType } from '@nscode/handy-ui'
interface ApprovalRecord {
id: number
time: string
text: string
type: TimelineItemType
}
const records = ref<ApprovalRecord[]>([
{ id: 1, time: '2026-01-01 09:00', text: 'Expense claim submitted', type: 'primary' },
{ id: 2, time: '2026-01-01 10:30', text: 'Manager approved', type: 'success' },
{ id: 3, time: '2026-01-02 14:00', text: 'Payment issued', type: 'success' }
])
const reverse = ref(false)
const steps = ['Add invoice', 'Finance review', 'Archive']
const add = () => {
const id = records.value.length + 1
const now = new Date()
const pad = (n: number) => String(n).padStart(2, '0')
records.value.push({
id,
time: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}`,
text: steps[(id - 4) % steps.length] ?? 'Other action',
type: 'info'
})
}
</script>
<template>
<HuiSpace direction="vertical" align="start">
<HuiSpace wrap>
<HuiButton type="primary" icon="plus" @click="add">Add record</HuiButton>
<HuiSwitch v-model="reverse" active-text="Newest first" />
</HuiSpace>
<HuiTimeline :reverse="reverse">
<HuiTimelineItem
v-for="record in records"
:key="record.id"
:timestamp="record.time"
:type="record.type"
>
{{ record.text }}
</HuiTimelineItem>
</HuiTimeline>
</HuiSpace>
</template>
HuiTimeline Props
| Prop | Type | Default | Description |
|---|---|---|---|
| reverse | boolean | false | Reverse display order, placing the last item at the top |
HuiTimelineItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
| timestamp | string | '' | Timestamp text; hidden when empty |
| hideTimestamp | boolean | false | Whether to hide the timestamp |
| placement | 'top' | 'bottom' | 'bottom' | Place the timestamp above (top) or below (bottom) the content |
| type | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | Node type and color |
| color | string | '' | Any CSS color for the node; takes precedence over type |
| size | 'normal' | 'large' | 'normal' | Node size |
| hollow | boolean | false | Whether the node is hollow |
HuiTimeline Slots
| Slot | Scope | Description |
|---|---|---|
| default | - | Contains HuiTimelineItem components |
HuiTimelineItem Slots
| Slot | Scope | Description |
|---|---|---|
| default | - | Content of this record |
| dot | - | Custom node replacing the default dot |
Types
import type {
TimelineProps,
TimelineItemProps,
TimelineItemType,
TimelineItemSize,
TimelineItemPlacement
} from '@nscode/handy-ui'
type TimelineItemType = 'primary' | 'success' | 'warning' | 'danger' | 'info'
type TimelineItemSize = 'normal' | 'large'
type TimelineItemPlacement = 'top' | 'bottom'
interface TimelineProps {
reverse?: boolean
}
interface TimelineItemProps {
timestamp?: string
hideTimestamp?: boolean
placement?: TimelineItemPlacement
type?: TimelineItemType
color?: string
size?: TimelineItemSize
hollow?: boolean
}
TimelineContext and the injection key TIMELINE_INJECTION_KEY are also exported for custom children that work with HuiTimeline.