Timeline 時間軸
縱向事件流。語意 <ol> 列表,時間順序即文件順序。
基礎用法
基礎用法
- 專案評審
- 一期交付
- 驗收進行中
- 規劃
- 開發
- 壓測
- 未開始
- 進行中
- 已完成
import { LhTimeline, LhTimelineItem } from '@lh-ui/react'
export default function Demo() {
return (
<LhTimeline>
<LhTimelineItem timestamp="2026-09-01">專案評審</LhTimelineItem>
<LhTimelineItem timestamp="2026-09-15" type="success">
一期交付
</LhTimelineItem>
<LhTimelineItem timestamp="2026-09-25" type="warning">
驗收進行中
</LhTimelineItem>
</LhTimeline>
)
}
mode="alternate" 開啟左右交替版面;hollow 讓節點顯示為空心圓點,常用於未完成的狀態。
Timeline Props
| 屬性 | 說明 | 類型 | 預設值 |
|---|---|---|---|
| mode | 版面配置模式(alternate 左右交替) | 'left' | 'alternate' | 'left' |
| sx | 快速版面配置屬性 | SxProps | — |
TimelineItem Props
| 屬性 | 說明 | 類型 | 預設值 |
|---|---|---|---|
| timestamp | 時間戳記 | ReactNode | — |
| type | 節點語意類型(圓點著色) | 'primary' | 'success' | 'warning' | 'danger' | — |
| hollow | 空心節點 | boolean | false |
| dot | 自訂圓點內容 | ReactNode | — |
| sx | 快速版面配置屬性 | SxProps | — |
插槽對照
plus 的三個插槽在 React 版合併為 props:#default → children、#timestamp → timestamp、#dot → dot。
子節點限制
children 必須直接是 LhTimelineItem(可用 .map 渲染),不可被自訂元件包裹 —— 父元件靠 Children.toArray 過濾子元素型別來注入 index / isLast,包裹會導致末項連接線與 alternate 交替側計算錯亂。
無障礙
- 語意
<ol>列表,時間順序即文件順序,螢幕閱讀器按序播報 - 節點圓點為純裝飾(
aria-hidden="true"),自訂圓點同樣不進入無障礙樹
ref
forwardRef<HTMLOListElement> —— <ol> 根元素。LhTimelineItem 轉發 HTMLLIElement。
樣式
import '@lh-ui/react/style/timeline'