網站導覽

v2.1.0
資料顯示

時間軸

依發生順序將事件排在一條線上,例如動態消息、歷史紀錄或更新日誌。

本頁內容

時間軸依事件發生的順序將它們排成一列,可用於活動動態、部署紀錄或變更日誌。時間軸是有序清單,每個事件的標記都排在同一欄,文字放在標記旁,並以一條細線串起所有標記。

時間軸

<ol class="timeline max-w(360) mx-auto">  <li class="timeline-item" aria-current="true">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Deployed to production</p>      <p class="timeline-description">atlas.dev is live in 14 regions.</p>      <time class="timeline-time" datetime="2026-11-11T09:42Z">2 minutes ago</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Build completed</p>      <p class="timeline-description">38 routes compiled in 48 seconds.</p>      <time class="timeline-time" datetime="2026-11-11T09:41Z">3 minutes ago</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Commit pushed to main</p>      <time class="timeline-time" datetime="2026-11-11T09:40Z">4 minutes ago</time>    </div>  </li></ol>
<ol className="timeline max-w(360) mx-auto">  <li className="timeline-item" aria-current="true">    <span className="timeline-marker"></span>    <div className="timeline-body">      <p className="timeline-title">Deployed to production</p>      <p className="timeline-description">atlas.dev is live in 14 regions.</p>      <time className="timeline-time" dateTime="2026-11-11T09:42Z">2 minutes ago</time>    </div>  </li>  <li className="timeline-item">    <span className="timeline-marker"></span>    <div className="timeline-body">      <p className="timeline-title">Build completed</p>      <p className="timeline-description">38 routes compiled in 48 seconds.</p>      <time className="timeline-time" dateTime="2026-11-11T09:41Z">3 minutes ago</time>    </div>  </li>  <li className="timeline-item">    <span className="timeline-marker"></span>    <div className="timeline-body">      <p className="timeline-title">Commit pushed to main</p>      <time className="timeline-time" dateTime="2026-11-11T09:40Z">4 minutes ago</time>    </div>  </li></ol>
<ol class="timeline max-w(360) mx-auto">  <li class="timeline-item" aria-current="true">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Deployed to production</p>      <p class="timeline-description">atlas.dev is live in 14 regions.</p>      <time class="timeline-time" datetime="2026-11-11T09:42Z">2 minutes ago</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Build completed</p>      <p class="timeline-description">38 routes compiled in 48 seconds.</p>      <time class="timeline-time" datetime="2026-11-11T09:41Z">3 minutes ago</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Commit pushed to main</p>      <time class="timeline-time" datetime="2026-11-11T09:40Z">4 minutes ago</time>    </div>  </li></ol>
<template>  <ol class="timeline max-w(360) mx-auto">    <li class="timeline-item" aria-current="true">      <span class="timeline-marker"></span>      <div class="timeline-body">        <p class="timeline-title">Deployed to production</p>        <p class="timeline-description">atlas.dev is live in 14 regions.</p>        <time class="timeline-time" datetime="2026-11-11T09:42Z">2 minutes ago</time>      </div>    </li>    <li class="timeline-item">      <span class="timeline-marker"></span>      <div class="timeline-body">        <p class="timeline-title">Build completed</p>        <p class="timeline-description">38 routes compiled in 48 seconds.</p>        <time class="timeline-time" datetime="2026-11-11T09:41Z">3 minutes ago</time>      </div>    </li>    <li class="timeline-item">      <span class="timeline-marker"></span>      <div class="timeline-body">        <p class="timeline-title">Commit pushed to main</p>        <time class="timeline-time" datetime="2026-11-11T09:40Z">4 minutes ago</time>      </div>    </li>  </ol></template>

#標記

空的 timeline-marker 會顯示為小圓點。加上 aria-current 的事件會以墨色和淡淡的光暈凸顯,可用來標示最新事件或讀者目前所在的事件。若標記內含 icon,就會以小型凹底襯托圖示,由 :has() 決定採用哪種樣式,因此同一份動態清單可混用兩種標記。

含圖示

<ol class="timeline max-w(360) mx-auto">  <li class="timeline-item">    <span class="timeline-marker">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />      </svg>    </span>    <div class="timeline-body">      <p class="timeline-title">Ada approved the change</p>      <time class="timeline-time">Today at 09:12</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3.5 2.5L12.5 2.5A1 1 0 0 1 13.5 3.5L13.5 10A1 1 0 0 1 12.5 11L7.777 11A1 1 0 0 0 7.2625 11.1425L4.0145 13.0913A1 1 0 0 1 2.5 12.2338L2.5 3.5A1 1 0 0 1 3.5 2.5Z" />      </svg>    </span>    <div class="timeline-body">      <p class="timeline-title">Alan left a comment</p>      <p class="timeline-description">The focus ring is cut by the mask. Move it to the group.</p>      <time class="timeline-time">Yesterday at 17:40</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Pull request opened</p>      <time class="timeline-time">Yesterday at 16:05</time>    </div>  </li></ol>
import CheckIcon from '@master/icons-react/native/16/soft/check'import MessageIcon from '@master/icons-react/native/16/soft/message'<ol className="timeline max-w(360) mx-auto">  <li className="timeline-item">    <span className="timeline-marker"><CheckIcon className="icon" /></span>    <div className="timeline-body">      <p className="timeline-title">Ada approved the change</p>      <time className="timeline-time">Today at 09:12</time>    </div>  </li>  <li className="timeline-item">    <span className="timeline-marker"><MessageIcon className="icon" /></span>    <div className="timeline-body">      <p className="timeline-title">Alan left a comment</p>      <p className="timeline-description">        The focus ring is cut by the mask. Move it to the group.      </p>      <time className="timeline-time">Yesterday at 17:40</time>    </div>  </li>  <li className="timeline-item">    <span className="timeline-marker"></span>    <div className="timeline-body">      <p className="timeline-title">Pull request opened</p>      <time className="timeline-time">Yesterday at 16:05</time>    </div>  </li></ol>
<script>  import CheckIcon from '@master/icons-svelte/native/16/soft/check'  import MessageIcon from '@master/icons-svelte/native/16/soft/message'</script><ol class="timeline max-w(360) mx-auto">  <li class="timeline-item">    <span class="timeline-marker"><CheckIcon class="icon" /></span>    <div class="timeline-body">      <p class="timeline-title">Ada approved the change</p>      <time class="timeline-time">Today at 09:12</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"><MessageIcon class="icon" /></span>    <div class="timeline-body">      <p class="timeline-title">Alan left a comment</p>      <p class="timeline-description">The focus ring is cut by the mask. Move it to the group.</p>      <time class="timeline-time">Yesterday at 17:40</time>    </div>  </li>  <li class="timeline-item">    <span class="timeline-marker"></span>    <div class="timeline-body">      <p class="timeline-title">Pull request opened</p>      <time class="timeline-time">Yesterday at 16:05</time>    </div>  </li></ol>
<script setup>import CheckIcon from '@master/icons-vue/native/16/soft/check'import MessageIcon from '@master/icons-vue/native/16/soft/message'</script><template>  <ol class="timeline max-w(360) mx-auto">    <li class="timeline-item">      <span class="timeline-marker"><CheckIcon class="icon" /></span>      <div class="timeline-body">        <p class="timeline-title">Ada approved the change</p>        <time class="timeline-time">Today at 09:12</time>      </div>    </li>    <li class="timeline-item">      <span class="timeline-marker"><MessageIcon class="icon" /></span>      <div class="timeline-body">        <p class="timeline-title">Alan left a comment</p>        <p class="timeline-description">The focus ring is cut by the mask. Move it to the group.</p>        <time class="timeline-time">Yesterday at 17:40</time>      </div>    </li>    <li class="timeline-item">      <span class="timeline-marker"></span>      <div class="timeline-body">        <p class="timeline-title">Pull request opened</p>        <time class="timeline-time">Yesterday at 16:05</time>      </div>    </li>  </ol></template>

#時間軸或步驟

時間軸記錄已發生的事,事件數量不固定,且每個事件都已完成。步驟呈現讀者正在依序完成的固定流程,標示目前進行到哪一步,其餘步驟都在後面。若要呈現仍在執行的工作,其中的步驟可能正在執行或已失敗,且可展開查看詳情,請使用追蹤紀錄。

#無障礙

  • 順序有意義時,請使用 <ol>。時間軸幾乎總是如此。每個時間點各用一個 <time>,並加上 datetime。
  • 標記和細線由樣式表繪製,螢幕閱讀器不會讀出。標記內的圖示是裝飾,請在標題中說明發生了什麼事。
  • 若動態清單在畫面上顯示時會更新,應使用帶有 aria-live="polite" 的即時區域。

#類別

類別說明
timeline清單
timeline-item一筆事件,以細線將它的標記接到下一筆事件的標記
timeline-marker留空時顯示小圓點,放入圖示時則顯示包住圖示的小底框。
timeline-body標記旁的文字
timeline-title以醒目的前景色顯示事件內容
timeline-description一行較低調的補充資訊。
timeline-time以等寬數字顯示事件發生的時間

#自訂屬性

屬性預設值說明
--timeline-marker1.5rem標記欄寬度

#原始碼

@master/ui/components/timeline.css
/* * Timeline: events in the order they happened, as a list on one line. * Each event has a marker on a column and its words beside it; a hairline joins the markers. A bare marker * is a small dot, and a marker that holds an icon becomes a small well around it. */@layer components.ui {  .timeline {    --timeline-marker: 1.5rem;    display: flex;    flex-direction: column;    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-body);    font-size: .875rem;    line-height: 1.5;    list-style: none;  }  .timeline-item {    position: relative;    display: flex;    align-items: flex-start;    gap: .75rem;    min-width: 0;    padding-block-end: 1.25rem;    &:last-child {      padding-block-end: 0;    }    /*     * The line runs from under this marker to the next one, 2px clear of each. A marker sits centered on the     * first line, (1lh - --timeline-marker) / 2 from the item's top, so both ends are counted from there.     */    &:not(:last-child)::before {      content: '';      position: absolute;      inset-block: calc((1lh + var(--timeline-marker)) / 2 + .125rem) calc(.125rem - (1lh - var(--timeline-marker)) / 2);      inset-inline-start: calc(var(--timeline-marker) / 2 - .5px);      width: 1px;      background: var(--color-line-divider);    }    @media (forced-colors: active) {      &:not(:last-child)::before {        background: CanvasText;      }    }  }  /* The marker's column is as tall as the first line of text, so the dot sits on that line. */  .timeline-marker {    --icon-size: .875rem;    --icon-color: var(--color-text-muted);    display: grid;    flex: none;    place-items: center;    width: var(--timeline-marker);    height: var(--timeline-marker);    margin-block: calc((1lh - var(--timeline-marker)) / 2);    border-radius: 999px;    /* Bare: a dot. */    &:empty::before {      content: '';      width: .4375rem;      height: .4375rem;      border-radius: 999px;      background: var(--color-line-mark);    }    /* With an icon: a small well around it. */    &:has(.icon) {      background: var(--color-surface-inset);      box-shadow: var(--shadow-pressed);    }    @media (forced-colors: active) {      &:empty::before {        background: CanvasText;      }      &:has(.icon) {        outline: 1px solid CanvasText;        outline-offset: -1px;      }    }  }  /* The newest or current event: its dot takes ink. */  .timeline-item[aria-current]:not([aria-current="false"]) .timeline-marker:empty::before {    background: var(--color-text-strong);    box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-text-strong) 12%, transparent);    /* A color that is not a system color would turn to Canvas here and the dot would vanish. */    @media (forced-colors: active) {      background: Highlight;    }  }  .timeline-body {    display: grid;    flex: 1 1 0;    gap: .125rem;    min-width: 0;  }  .timeline-title {    margin: 0;    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    text-wrap: balance;    overflow-wrap: anywhere;  }  .timeline-description {    margin: 0;    color: var(--color-text-muted);    font-size: .8125rem;    text-wrap: pretty;    overflow-wrap: anywhere;  }  /* When it happened: a quiet line in tabular figures. */  .timeline-time {    margin: 0;    color: var(--color-text-muted);    font-size: .75rem;    font-variant-numeric: tabular-nums;  }}