Back to Ant Design

Timeline

components/timeline/index.zh-CN.md

6.3.73.6 KB
Original Source

何时使用 {#when-to-use}

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

代码演示 {#examples}

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">基本用法</code> <code src="./demo/variant.tsx">变体样式</code> <code src="./demo/pending.tsx">等待及排序</code> <code src="./demo/pending-legacy.tsx" debug>最后一个及排序</code> <code src="./demo/alternate.tsx">交替展现</code> <code src="./demo/horizontal.tsx">水平布局</code> <code src="./demo/horizontal-debug.tsx" debug>水平布局</code> <code src="./demo/custom.tsx">自定义时间轴点</code> <code src="./demo/end.tsx">另一侧时间轴点</code> <code src="./demo/title.tsx">标题</code> <code src="./demo/title-span.tsx">标题占比</code> <code src="./demo/semantic.tsx">语义化自定义</code> <code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code> <code src="./demo/component-token.tsx" debug>组件 Token</code>

API

通用属性参考:通用属性

Timeline

参数说明类型默认值版本
classNames用于自定义组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
items选项配置Items[]-
mode通过设置 mode 可以改变时间轴和内容的相对位置start | alternate | endstart
orientation设置时间轴的方向vertical | horizontalvertical
pending指定最后一个幽灵节点是否存在或内容,请使用 item.loading 代替ReactNodefalse
pendingDot当最后一个幽灵节点存在時,指定其时间图点,请使用 item.icon 代替ReactNode<LoadingOutlined />
reverse节点排序booleanfalse
styles用于自定义组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
titleSpan设置标题占比空间,为到 dot 中心点距离 <InlinePopover previewURL="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*1NJISa7bpqgAAAAAR5AAAAgAerJ8AQ/original"></InlinePopover>number | string12
variant设置样式变体filled | outlinedoutlined

Items

时间轴的每一个节点。

参数说明类型默认值
color指定圆圈颜色 blueredgreengray,或自定义的色值stringblue
content设置内容ReactNode-
children设置内容,请使用 content 替换ReactNode-
dot自定义时间轴点,请使用 icon 替换ReactNode-
icon自定义节点图标ReactNode-
label设置标签,请使用 title 替换ReactNode-
loading设置加载状态booleanfalse
placement自定义节点位置start | end-
position自定义节点位置,请使用 placement 替换start | end-
title设置标题ReactNode-

Semantic DOM

Timeline

<code src="./demo/_semantic.tsx" simplify="true"></code>

Timeline Items

<code src="./demo/_semantic_items.tsx" simplify="true"></code>

主题变量(Design Token){#design-token}

<ComponentTokenTable component="Timeline"></ComponentTokenTable>