Timeline

Slant / Data

A vertical or horizontal timeline of checkpoints with live and fresh states.

Demo

Checkpoint timeline

Usage

@tuttn/slant
import { Timeline } from '@tuttn/slant'

// The data form: one entry per item, top to bottom. The ref goes to the <ol>.
<Timeline ref={listRef} items={[
  { id: 'created', title: 'Task created', meta: 'From the backlog', time: '2h ago', done: true },
  { id: 'saved', title: 'Checkpoint saved', meta: '3 files', time: '1h ago', done: true },
  // live announces changes; fresh plays the pop animation once.
  { id: 'merge', title: merged ? 'Merged' : 'Merge', meta: 'Waiting for you', done: merged, fresh: merged, live: true },
]} />

// Horizontal: equal columns from the inline start, node on top, text under it.
<Timeline orientation="horizontal" items={stages} aria-label="Release stages" />

Props

PropTypeDefaultDescription
itemsTimelineItem[]—The entries in order, top to bottom, or from the inline start when horizontal: `{ id, title, meta?, time?, done?, fresh?, live? }`.
orientation'vertical' | 'horizontal''vertical'Vertical stacks the entries with the connector running down. Horizontal lays them in equal columns, node on top, the connector along the inline axis (so it mirrors under RTL) and the text under it. Rendered as `data-orientation`.
item.idstring—A stable key.
item.title / meta / timeReactNode—The headline (required), the detail line, and the time: at the end of the row, or under the text when horizontal.
item.donebooleanfalseFills the node; undone titles are muted.
item.freshbooleanfalsePlays the pop animation on the node.
item.livebooleanfalseMakes the entry a polite live region.
…restHTMLAttributes<HTMLOListElement>—className, style, the ref and other attributes go on the <ol>.

The timeline is an ordered list, so screen readers hear how many steps there are and where each one sits. It takes no focus and has no keyboard behaviour. An entry marked live is a polite live region: change its title or meta and the change is read out.

orientation="horizontal" lays the entries in equal columns, with the node on top, the connector running along the inline axis to the next node, and the text under it. The columns share the width and the text wraps, so there is never a scrolling container: keep a horizontal timeline to a handful of short steps, and use the vertical one for a long history. The orientation is rendered as data-orientation.

Both layouts use logical properties, so under dir="rtl" they mirror: the vertical connector moves to the right edge, and a horizontal timeline runs from the right.

Full source