Timeline
Dated entries on a rail that highlights the entry being read.
Now
Public launch
Open to everyone, with a free plan and docs for every feature.
Sep 2026
Open beta
The first thousand teams try it out and help shape the roadmap.
Jun 2026
Private alpha
Ten design partners use it every day and report what breaks.
Mar 2026
First prototype
A rough build that proves the core idea works.
Jan 2026
Kickoff
A problem worth solving, and a small team to solve it.
<Timeline label="Product timeline" scrollRoot={scroller}>
<TimelineEntry id="launch" date="Now" title="Public launch">
<p>Open to everyone, with a free plan and docs for every feature.</p>
</TimelineEntry>
<TimelineEntry id="beta" date="Sep 2026" title="Open beta">
<p>The first thousand teams try it out and help shape the roadmap.</p>
</TimelineEntry>
</Timeline>Installation
CLI
pnpm dlx shadcn@latest add @riff/timelineManual
Copy the component
Save this as
components/ui/timeline.tsx:'use client'; import { Children, createContext, use, useEffect, useRef, useState, type ReactNode, type RefObject, } from 'react'; import './timeline.css'; const ActiveEntry = createContext<string | undefined>(undefined); /** * Dated entries on a rail. The entry in the upper reading zone lights its * node, date and the rail below it; on wide layouts each date and node stay * stuck beside its entry while the entry scrolls past. */ export function Timeline({ label, scrollRoot, onActiveChange, children, }: { /** Names the list for screen readers. */ label: string; /** The element that scrolls the entries; the window when omitted. */ scrollRoot?: RefObject<HTMLElement | null>; /** Called with the active entry's id, such as to sync a sidebar. */ onActiveChange?: (id: string) => void; children: ReactNode; }) { const list = useRef<HTMLOListElement>(null); const [active, setActive] = useState<string>(); const count = Children.count(children); const notify = useRef(onActiveChange); useEffect(() => { notify.current = onActiveChange; }); useEffect(() => { const root = scrollRoot?.current ?? null; const entries = [ ...(list.current?.querySelectorAll<HTMLElement>( ':scope > .riff-timeline-entry', ) ?? []), ]; const [first] = entries; if (!count || !first) return; const visible = new Set<Element>(); let frame = 0; const choose = (id: string) => { setActive((current) => { if (current !== id) notify.current?.(id); return id; }); }; const pick = () => { frame = 0; const top = root ? root.getBoundingClientRect().top : 0; const height = root ? root.clientHeight : innerHeight; const scrolled = root ? root.scrollTop : scrollY; const total = root ? root.scrollHeight : document.documentElement.scrollHeight; // At the very bottom the last entry may never reach the reading zone. const last = entries.at(-1); if (last && scrolled + height >= total - 48) return choose(last.id); const inZone = entries.find((entry) => visible.has(entry)); if (inZone) return choose(inZone.id); let current = first.id; for (const entry of entries) if (entry.getBoundingClientRect().top - top <= height * 0.35) current = entry.id; choose(current); }; const schedule = () => { if (!frame) frame = requestAnimationFrame(pick); }; const observer = new IntersectionObserver( (records) => { for (const record of records) if (record.isIntersecting) visible.add(record.target); else visible.delete(record.target); schedule(); }, { root, rootMargin: '-12% 0px -58% 0px' }, ); for (const entry of entries) observer.observe(entry); const target = root ?? window; target.addEventListener('scroll', schedule, { passive: true }); pick(); return () => { cancelAnimationFrame(frame); observer.disconnect(); target.removeEventListener('scroll', schedule); }; // Rebinds when entries are added or removed. }, [scrollRoot, count]); return ( <ActiveEntry value={active}> <ol ref={list} className="riff-timeline" aria-label={label}> {children} </ol> </ActiveEntry> ); } /** One entry: its date and node on the rail, then its title and content. */ export function TimelineEntry({ id, date, title, children, }: { /** A unique id, also the entry's link target. */ id: string; /** A month and year, or a year. */ date: ReactNode; title: ReactNode; children?: ReactNode; }) { const active = use(ActiveEntry) === id; return ( <li id={id} className="riff-timeline-entry" data-active={active ? '' : undefined} aria-current={active ? 'step' : undefined} > <p className="riff-timeline-date">{date}</p> <div className="riff-timeline-rail" aria-hidden="true"> <span className="riff-timeline-node" /> <span className="riff-timeline-line" /> </div> <div className="riff-timeline-content"> <h3 className="riff-timeline-title">{title}</h3> {children && <div className="riff-timeline-body">{children}</div>} </div> </li> ); }Copy its styles
Save this beside it as
timeline.css:/* Host roles first, system colours after: the component reads your theme when it has these properties and stays legible when it does not. Narrow layouts stack the date over the title; from 36rem wide the date moves left of the rail and stays stuck beside its entry with the node. */ @layer components { .riff-timeline { --riff-timeline-node: 0.75rem; --riff-timeline-gap: 0.375rem; --riff-timeline-sticky-top: 1rem; --riff-timeline-accent: var(--color-primary, Highlight); --riff-timeline-surface: var(--color-background, Canvas); --riff-timeline-rest: color-mix( in oklab, var(--color-muted-foreground, GrayText) 40%, var(--riff-timeline-surface) ); --riff-timeline-halo: color-mix( in oklab, var(--riff-timeline-accent) 18%, transparent ); container-type: inline-size; display: flex; flex-direction: column; margin: 0; padding: 0; color: var(--color-foreground, CanvasText); list-style: none; } .riff-timeline-entry { /* Centres the node on the first line beside it. */ --riff-timeline-offset: calc( (0.8125rem * 1.35 - var(--riff-timeline-node)) / 2 ); display: grid; grid-template-areas: 'rail date' 'rail content'; grid-template-columns: 1rem minmax(0, 1fr); column-gap: 1rem; row-gap: 0.25rem; scroll-margin-top: 4rem; } .riff-timeline-date { grid-area: date; margin: 0; color: var(--color-muted-foreground, GrayText); font-size: 0.8125rem; font-variant-numeric: tabular-nums; font-weight: 500; line-height: 1.35; white-space: nowrap; transition: color 150ms cubic-bezier(0, 0, 0.2, 1); } .riff-timeline-rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; padding-top: var(--riff-timeline-offset); } .riff-timeline-node { width: var(--riff-timeline-node); height: var(--riff-timeline-node); flex-shrink: 0; border-radius: 999px; background-color: var(--riff-timeline-rest); transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1), box-shadow 150ms cubic-bezier(0, 0, 0.2, 1); } .riff-timeline-line { width: 1.5px; flex: 1; margin-block: var(--riff-timeline-gap) calc(var(--riff-timeline-gap) - var(--riff-timeline-offset)); border-radius: 999px; background-color: var(--color-border, GrayText); transition: background-color 200ms cubic-bezier(0, 0, 0.2, 1); } .riff-timeline-entry:last-child .riff-timeline-line { visibility: hidden; } .riff-timeline-content { grid-area: content; display: flex; min-width: 0; flex-direction: column; gap: 0.75rem; padding-bottom: 3.5rem; } .riff-timeline-entry:last-child .riff-timeline-content { padding-bottom: 0; } .riff-timeline-title { margin: 0; font-size: 1.125rem; font-weight: 500; letter-spacing: -0.015em; line-height: 1.35; text-wrap: balance; } .riff-timeline-body { display: flex; flex-direction: column; gap: 0.75rem; color: var(--color-muted-foreground, GrayText); font-size: 0.9375rem; line-height: 1.65; & > * { margin: 0; } } .riff-timeline-entry[data-active] { .riff-timeline-date { color: var(--riff-timeline-accent); } .riff-timeline-node { background-color: var(--riff-timeline-accent); box-shadow: 0 0 0 4px var(--riff-timeline-halo); } .riff-timeline-line { background-color: color-mix( in oklab, var(--riff-timeline-accent) 55%, var(--color-border, GrayText) ); } } @container (min-width: 36rem) { .riff-timeline-entry { --riff-timeline-offset: calc( (1.125rem * 1.35 - var(--riff-timeline-node)) / 2 ); grid-template-areas: 'date rail content'; grid-template-columns: 4.5rem 1rem minmax(0, 1fr); column-gap: 0.75rem; } /* The date's and title's first lines share one centre. */ .riff-timeline-date { position: sticky; top: var(--riff-timeline-sticky-top); align-self: start; padding-top: calc((1.125rem - 0.8125rem) * 1.35 / 2); text-align: end; } /* A ring of page colour keeps the line's gap as the node slides. */ .riff-timeline-node { position: sticky; z-index: 1; top: calc(var(--riff-timeline-sticky-top) + var(--riff-timeline-offset)); box-shadow: 0 0 0 var(--riff-timeline-gap) var(--riff-timeline-surface); } .riff-timeline-entry[data-active] .riff-timeline-node { box-shadow: 0 0 0 4px var(--riff-timeline-halo), 0 0 0 calc(4px + var(--riff-timeline-gap)) var(--riff-timeline-surface); } .riff-timeline-content { padding-bottom: 4.5rem; } } @media (prefers-reduced-motion: reduce) { .riff-timeline-date, .riff-timeline-node, .riff-timeline-line { transition: none; } } }
Usage
import { Timeline, TimelineEntry } from '@/components/ui/timeline';
<Timeline label="Changelog">
<TimelineEntry id="v2" date="Mar 2026" title="Version 2">
<p>A new editor.</p>
</TimelineEntry>
<TimelineEntry id="v1" date="Jan 2026" title="Version 1" />
</Timeline>;The entry in the upper part of the view lights up as the reader scrolls. From 36rem wide, dates move left of the rail and stick beside their entry; set --riff-timeline-sticky-top to clear a fixed header. Use onActiveChange to sync a sidebar.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Names the list. | |
scrollRoot | RefObject<HTMLElement> | window | The element that scrolls the entries. |
onActiveChange | (id: string) => void | Called with the active entry’s id. | |
TimelineEntry.id | string | Unique; also the entry’s link target. | |
TimelineEntry.date | ReactNode | Beside the rail. | |
TimelineEntry.title | ReactNode | The entry’s heading. |