logoAnt Design

⌘ K
  • 设计
  • 研发
  • 组件
  • 博客
  • 资源
  • 国内镜像
5.20.6
  • 组件总览
  • 通用
    • Button
      按钮
    • FloatButton
      悬浮按钮
      5.0.0
    • Icon
      图标
    • Typography
      排版
  • 布局
    • Divider
      分割线
    • Flex
      弹性布局
      5.10.0
    • Grid
      栅格
    • Layout
      布局
    • Space
      间距
  • 导航
    • Anchor
      锚点
    • Breadcrumb
      面包屑
    • Dropdown
      下拉菜单
    • Menu
      导航菜单
    • Pagination
      分页
    • Steps
      步骤条
  • 数据录入
    • AutoComplete
      自动完成
    • Cascader
      级联选择
    • Checkbox
      多选框
    • ColorPicker
      颜色选择器
      5.5.0
    • DatePicker
      日期选择框
    • Form
      表单
    • Input
      输入框
    • InputNumber
      数字输入框
    • Mentions
      提及
    • Radio
      单选框
    • Rate
      评分
    • Select
      选择器
    • Slider
      滑动输入条
    • Switch
      开关
    • TimePicker
      时间选择框
    • Transfer
      穿梭框
    • TreeSelect
      树选择
    • Upload
      上传
  • 数据展示
    • Avatar
      头像
    • Badge
      徽标数
    • Calendar
      日历
    • Card
      卡片
    • Carousel
      走马灯
    • Collapse
      折叠面板
    • Descriptions
      描述列表
    • Empty
      空状态
    • Image
      图片
    • List
      列表
    • Popover
      气泡卡片
    • QRCode
      二维码
      5.1.0
    • Segmented
      分段控制器
    • Statistic
      统计数值
    • Table
      表格
    • Tabs
      标签页
    • Tag
      标签
    • Timeline
      时间轴
    • Tooltip
      文字提示
    • Tour
      漫游式引导
      5.0.0
    • Tree
      树形控件
  • 反馈
    • Alert
      警告提示
    • Drawer
      抽屉
    • Message
      全局提示
    • Modal
      对话框
    • Notification
      通知提醒框
    • Popconfirm
      气泡确认框
    • Progress
      进度条
    • Result
      结果
    • Skeleton
      骨架屏
    • Spin
      加载中
    • Watermark
      水印
      5.1.0
  • 其他
    • Affix
      固钉
    • App
      包裹组件
      5.1.0
    • ConfigProvider
      全局化配置
    • Util
      工具类
      5.13.0

Timeline
时间轴

垂直展示的时间流信息。
使用import{ Timeline }from"antd";
源码components/timeline
文档编辑此页

相关资源

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-首页模板集
Scaffolds-脚手架市场
Umi-React 应用开发框架
dumi-组件/文档研发工具
qiankun-微前端框架
ahooks-React Hooks 库
Ant Motion-设计动效
国内镜像站点 🇨🇳

社区

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design 语雀专栏
Ant Design 知乎专栏
体验科技专栏
seeconf logoSEE Conf-蚂蚁体验科技大会
加入我们

帮助

GitHub
更新日志
常见问题
报告 Bug
议题
讨论区
StackOverflow
SegmentFault

Ant XTech logo更多产品

yuque logo语雀-构建你的数字花园
AntV logoAntV-数据可视化解决方案
Egg logoEgg-企业级 Node.js 框架
Kitchen logoKitchen-Sketch 工具集
Galacean logoGalacean-互动图形解决方案
xtech logo蚂蚁体验科技
主题编辑器
Made with ❤ by
蚂蚁集团和 Ant Design 开源社区
loading

何时使用

  • 当有一系列信息需按时间排列时,可正序和倒序。
  • 需要有一条时间轴进行视觉上的串联时。
升级提示

5.2.0 版本之后,我们提供了更简单的用法 <Timeline items={[...]} /> 以获得更好的性能,使您能在应用中编写更简单的代码。 与此同时,我们弃用了旧的用法,并且将在下一个 major 版本中删除它。

// >=5.2.0 可用,推荐的写法 ✅
const items = [{ children: 'sample', label: 'sample' }];
return <Timeline items={items} />;
// <5.2.0 可用,>=5.2.0 时不推荐 🙅🏻‍♀️
return (
<Timeline onChange={onChange}>
<Timeline.Item>Sample</Timeline.Item>
</Timeline>
);

代码演示

  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Technical testing 2015-09-01
  • Network problems being solved 2015-09-01
基本用法

基本的时间轴。

codepen icon
External Link Icon
expand codeexpand code
  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Technical testing 2015-09-01
  • Recording...
最后一个及排序

当任务状态正在发生,还在记录过程中,可用幽灵节点来表示当前的时间节点,当 pending 为真值时展示幽灵节点,如果 pending 是 React 元素可用于定制该节点内容,同时 pendingDot 将可以用于定制其轴点。reverse 属性用于控制节点排序,为 false 时按正序排列,为 true 时按倒序排列。

codepen icon
External Link Icon
expand codeexpand code
  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Technical testing 2015-09-01
  • Network problems being solved 2015-09-01
自定义时间轴点

可以设置为图标或其他自定义元素。

codepen icon
External Link Icon
expand codeexpand code
  • 2015-09-01
    Create a services
  • 2015-09-01 09:12:11
    Solve initial network problems
  • Technical testing
  • 2015-09-01 09:12:11
    Network problems being solved
标签

使用 label 标签单独展示时间。

codepen icon
External Link Icon
expand codeexpand code
  • Create a services site 2015-09-01
  • Create a services site 2015-09-01
  • Solve initial network problems 1

    Solve initial network problems 2

    Solve initial network problems 3 2015-09-01

  • Technical testing 1

    Technical testing 2

    Technical testing 3 2015-09-01

  • Technical testing 1

    Technical testing 2

    Technical testing 3 2015-09-01

  • Technical testing 1

    Technical testing 2

    Technical testing 3 2015-09-01

  • Custom color testing

圆圈颜色

圆圈颜色,绿色用于已完成、成功状态,红色表示告警或错误状态,蓝色可表示正在进行或其他默认状态,灰色表示未完成或失效状态。

codepen icon
External Link Icon
expand codeexpand code
  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
  • Network problems being solved 2015-09-01
  • Create a services site 2015-09-01
  • Technical testing 2015-09-01
交替展现

内容在时间轴两侧轮流出现。

codepen icon
External Link Icon
expand codeexpand code
  • Create a services site 2015-09-01
  • Solve initial network problems 2015-09-01
  • Technical testing 2015-09-01
  • Network problems being solved 2015-09-01
右侧时间轴点

时间轴点可以在内容的右边。

codepen icon
External Link Icon
expand codeexpand code

API

通用属性参考:通用属性

Timeline

参数说明类型默认值
mode通过设置 mode 可以改变时间轴和内容的相对位置left | alternate | right-
pending指定最后一个幽灵节点是否存在或内容ReactNodefalse
pendingDot当最后一个幽灵节点存在時,指定其时间图点ReactNode<LoadingOutlined />
reverse节点排序booleanfalse
items选项配置Items[]5.2.0

Items

时间轴的每一个节点。

参数说明类型默认值
color指定圆圈颜色 blue、red、green、gray,或自定义的色值stringblue
dot自定义时间轴点ReactNode-
label设置标签ReactNode-
children设置内容ReactNode-
position自定义节点位置left | right-

主题变量(Design Token)

组件 Token如何定制?

Token 名称描述类型默认值
dotBg节点背景色string#ffffff
dotBorderWidth节点边框宽度string | number2
itemPaddingBottom时间项下间距number20
tailColor轨迹颜色stringrgba(5, 5, 5, 0.06)
tailWidth轨迹宽度string | number2

全局 Token如何定制?