Cómo funciona
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.
Úsalo para
- 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.
Busca otra opción cuando
- Many unrelated events that people filter and sort: use a table.
Uso
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,
}))}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
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. |
Accesibilidad
- 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.
Movimiento
Entries: 560ms rise with a 70ms stagger on the reveal curve; rails draw 160ms later. Details: 360ms row expansion.
Añádelo a tu proyecto
Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.
Timeline.jsxtimeline.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.



