跳转到内容
Nacre
组件配色
EN

时间轴 Timeline

experimentalTimeline在画廊运行
Timeline
在浏览器里运行真实组件。

一列按时间排的节点:工单处理记录、通话的各个阶段。只管圆点与连线(末项无连线、当前节点外加同色细环),正文由调用方给;顺序(最新在顶还是在底)由调用方排。

状态:experimental · 组件:Timeline

import { Timeline } from 'nacre'

每项给 id、time(已格式化,在正文上一行)、content;最新一条用 marker=“strong”,历史用 subtle。圆点停在首行的中线上,末项下面不画连线。

import { View } from 'nsh'
import { Timeline } from 'nacre'
export function TimelineUsage() {
return (
<View class="w-[320px] max-w-full">
<Timeline
testID="timeline-usage"
items={[
{
id: '3',
time: '2026-11-05 14:20',
marker: 'strong',
content: '林嘉怡 将工单标记为已完结',
testID: 'timeline-usage-first',
},
{ id: '2', time: '2026-11-05 10:02', marker: 'subtle', content: '陈思远 接手处理' },
{ id: '1', time: '2026-11-04 18:45', marker: 'subtle', content: '客户创建工单', testID: 'timeline-usage-last' },
]}
/>
</View>
)
}

通话这类有颜色语义的阶段用 marker 的状态色;进行中所处的阶段 current,圆点外加一圈同色细环、读屏报当前步骤。「当前」这类文字标记由调用方写在 content 里。md 用在详情面板,间距大一档。

import { Text, View } from 'nsh'
import { Timeline, TEXT_SIZE } from 'nacre'
export function TimelineCurrent() {
return (
<View class="w-[320px] max-w-full">
<Timeline
testID="timeline-current"
size="md"
items={[
{ id: 'ivr', marker: 'default', content: '进入 IVR' },
{ id: 'queue', marker: 'muted', content: '排队 · 32 秒' },
{
id: 'talk',
marker: 'success',
current: true,
testID: 'timeline-current-node',
content: (
<View class="flex-row items-baseline gap-1.5">
<Text class={`${TEXT_SIZE.small} text-foreground`}>通话中</Text>
<Text class={`${TEXT_SIZE.caption} text-success-text`}>当前</Text>
</View>
),
},
]}
/>
</View>
)
}

content 可以是多行与标签的组合;连线跟着正文拉长,圆点仍对齐首行。

import { Text, View } from 'nsh'
import { Tag, Timeline, TEXT_SIZE } from 'nacre'
export function TimelineRich() {
return (
<View class="w-[280px] max-w-full">
<Timeline
testID="timeline-rich"
items={[
{
id: 'b',
time: '2026-11-05 09:30',
marker: 'warning',
testID: 'timeline-rich-long',
content: (
<View class="gap-0.5">
<Text class={`${TEXT_SIZE.small} text-foreground`}>
工单被退回:处理结论缺少客户确认的截图,请补充后重新提交。
</Text>
<View class="flex-row items-center gap-1.5">
<Text class={`${TEXT_SIZE.caption} text-muted-foreground`}>王敏</Text>
<Tag label="质检" />
</View>
</View>
),
},
{ id: 'a', time: '2026-11-04 16:12', marker: 'subtle', content: '提交处理结论' },
]}
/>
</View>
)
}
  • 容器是 list,读屏按顺序读每项的时间与正文。
  • current 的节点报 current(step);只靠颜色表达状态时,正文里写出状态文字。

该用

  • 正文首行用 text-small,和圆点对齐
  • 用状态色表达阶段的好坏时在正文里写出状态
  • 超过 5 条时由调用方折起,给「查看全部」

不该用

  • 当步骤条 / 向导用
  • 每项都用强调色
  • 在 Timeline 里放可编辑的表单
属性 类型 默认 说明
items * readonly TimelineItem[] — 从上到下的顺序由调用方排(最新在顶或在底)
size 'sm' | 'md' — sm(默认):右栏,圆点与正文间 8、节点间 10;md:详情面板,间 12、节点间 12
testID string —

* 必填