仕組み
An ordered list where each entry is a two-column grid: the marker and a hairline rail that runs from under it to the next marker, so the line never pokes out past the last entry. Markers are soft tinted discs with a 15px icon, or ringed dots; neutral entries stay grey so coloured ones stand out. The actor is set in ink and the action in a quieter grey, with the time right-aligned in tabular figures. On mount entries rise in one after another and each rail segment draws downward. A detail opens by animating grid rows from 0fr to 1fr, so nothing is measured, and it is inert while closed.
向いている場面
- The history of one object: a release, a ticket, a document, a shipment.
- An audit trail where who did what, and when, matters more than the exact values.
向かない場面
- Many unrelated events that people filter and sort: use a table.
使い方
import { Timeline } from './Timeline.jsx'
export function ReleaseActivity({ events }) {
return (
<Timeline
label="Release activity"
items={events.map((e) => ({
id: e.id,
actor: e.who,
title: e.what,
time: e.relativeTime,
dateTime: e.iso,
tone: e.failed ? 'danger' : 'neutral',
icon: <EventIcon kind={e.kind} />,
detail: e.comment,
}))}
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
items | { id?, actor?: ReactNode, title: ReactNode, time?: string, dateTime?: string, description?: ReactNode, detail?: ReactNode, icon?: ReactNode, tone?: 'accent' | 'success' | 'warning' | 'danger' | 'neutral' }[] | — | Entries, newest first or oldest first as you like. actor is set in ink before the title; detail adds a show/hide button and opens in a soft panel; tone colours the marker. |
variant | 'icon' | 'dot' | 'icon' | A 30px tinted disc with the item's icon, or a small ringed dot. |
density | 'comfortable' | 'compact' | 'comfortable' | 22px or 12px between entries. |
defaultOpen | (string | number)[] | [] | Ids (or indexes) of entries whose detail starts open. |
label / labels | string / { show, hide } | 'Activity' | Accessible name of the list, and the text of the detail button. |
アクセシビリティ
- The timeline is an ordered list with an accessible name; markers and the rail are hidden from screen readers.
- Times use the time element with an optional machine-readable dateTime.
- Each detail button reports aria-expanded and points at its panel with aria-controls; a closed panel is inert, so its content is skipped by Tab and screen readers.
- Reduced motion removes the rise and the rail draw; details only fade.
モーション
Entries: 560ms rise with a 70ms stagger on the reveal curve; rails draw 160ms later. Details: 360ms row expansion.
プロジェクトに追加
プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。
Timeline.jsxtimeline.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。



