Shadcn Timeline
A list of events in order, each with a marker, a connecting line, a title, a time and a description. Events can be marked complete, current or upcoming, run vertically or horizontally, and turn into an accessible feed that loads more as people scroll. Arrow keys move between events and every event is named by its title for screen readers.
Installation
npx shadcn@latest add @shadcnuikit/timeline1
This adds components/ui/timeline.tsx and a demo file. Set up the registry once as described in Shadcn CLI. Timeline is free and installs without an API key.
Manual installation
Install the dependencies:
npm install @ui-sdk/react@beta
Copy the source into components/ui/timeline.tsx:
"use client";
import * as React from "react";import { Timeline as TimelinePrimitive, TimelineConnector as TimelineConnectorPrimitive, TimelineDescription as TimelineDescriptionPrimitive, TimelineItem as TimelineItemPrimitive, TimelineMarker as TimelineMarkerPrimitive, TimelineTime as TimelineTimePrimitive, TimelineTitle as TimelineTitlePrimitive, createTimelineController, type TimelineStatus,} from "@ui-sdk/react/timeline";
import { cn } from "@/lib/utils";
type WithClassName<T> = Omit<T, "className"> & { className?: string };
function Timeline({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelinePrimitive>>) { return ( <TimelinePrimitive className={cn("flex w-full flex-col data-horizontal:flex-row", className)} {...props} /> );}
function TimelineItem({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineItemPrimitive>>) { return ( <TimelineItemPrimitive className={cn( "group/timeline-item relative flex flex-col gap-0.5 rounded-sm ps-9 pb-8 outline-none last:pb-0 data-last:pb-0", "focus-visible:outline-ring/50 focus-visible:outline-2 focus-visible:outline-offset-4", "data-horizontal:flex-1 data-horizontal:ps-0 data-horizontal:pe-6 data-horizontal:pt-9 data-horizontal:pb-0 data-horizontal:last:pe-0", className, )} {...props} /> );}
function TimelineMarker({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineMarkerPrimitive>>) { return ( <TimelineMarkerPrimitive className={cn( "bg-background border-border text-muted-foreground absolute start-0 top-0 z-10 flex size-6 items-center justify-center rounded-full border-2 [&_svg:not([class*='size-'])]:size-3.5", "empty:after:bg-muted-foreground/50 empty:after:size-2 empty:after:rounded-full empty:after:content-['']", "data-complete:bg-primary data-complete:border-primary data-complete:text-primary-foreground data-complete:after:bg-primary-foreground", "data-current:border-primary data-current:text-primary data-current:ring-primary/15 data-current:ring-4 data-current:after:bg-primary", className, )} {...props} /> );}
function TimelineConnector({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineConnectorPrimitive>>) { return ( <TimelineConnectorPrimitive className={cn( "bg-border absolute start-[calc(0.75rem-1px)] top-7 bottom-1 w-0.5 rounded-full", "group-last/timeline-item:hidden group-data-last/timeline-item:hidden", "data-complete:bg-primary", "data-horizontal:start-7 data-horizontal:end-1 data-horizontal:top-[calc(0.75rem-1px)] data-horizontal:bottom-auto data-horizontal:h-0.5 data-horizontal:w-auto", className, )} {...props} /> );}
function TimelineTitle({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineTitlePrimitive>>) { return ( <TimelineTitlePrimitive className={cn( "text-foreground text-sm leading-6 font-medium data-upcoming:text-muted-foreground", className, )} {...props} /> );}
function TimelineTime({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineTimePrimitive>>) { return ( <TimelineTimePrimitive className={cn("text-muted-foreground text-xs", className)} {...props} /> );}
function TimelineDescription({ className, ...props}: WithClassName<React.ComponentProps<typeof TimelineDescriptionPrimitive>>) { return ( <TimelineDescriptionPrimitive className={cn("text-muted-foreground mt-1 text-sm", className)} {...props} /> );}
export { Timeline, TimelineConnector, TimelineDescription, TimelineItem, TimelineMarker, TimelineTime, TimelineTitle, createTimelineController,};export type { TimelineStatus };
Usage
import {
Timeline,
TimelineConnector,
TimelineDescription,
TimelineItem,
TimelineMarker,
TimelineTime,
TimelineTitle,
} from "@/components/ui/timeline";
<Timeline aria-label="Order history">
<TimelineItem status="complete">
<TimelineMarker />
<TimelineConnector />
<TimelineTitle>Order placed</TimelineTitle>
<TimelineTime dateTime="2026-11-20">Nov 20</TimelineTime>
<TimelineDescription>We received your order.</TimelineDescription>
</TimelineItem>
</Timeline>
Give the timeline a name with aria-label or aria-labelledby. Put TimelineMarker and TimelineConnector first in each item. They are positioned absolutely, and the connector hides itself on the last item.
Status
<TimelineItem status="current">...</TimelineItem>
status is set on the item and every part inside reads it. Leave it out for plain activity logs that have no progress.
Examples
Basic
Without a status, every marker shows a muted dot.
Status
status accepts complete, current and upcoming. Complete fills the marker and the connector, current adds a ring, upcoming mutes the title.
Horizontal
orientation="horizontal" lays the events out in a row. Left and right arrow keys move between them.
Icon
Put an icon inside TimelineMarker instead of the default dot. Icons get size-3.5 unless you set a size.
Feed
feed turns the timeline into a feed of articles with their position and the total. Set busy while new events load.
Controller
createTimelineController() moves focus to an event by its value from outside the timeline.
More layouts built with Timeline, such as order tracking, changelogs and repository activity, are on the Timeline components page.
API Reference
Timeline
The root. Renders a div with role="list", or role="feed" with feed.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical", "horizontal" | "vertical" | Which way the events run, which also picks the arrow keys that move between them. |
loop | boolean | true | Whether arrow keys wrap from the last event to the first. |
feed | boolean | false | Makes the events a feed. Each event becomes an article with aria-posinset and aria-setsize. |
busy | boolean | false | Sets aria-busy while a feed loads or changes events. Only a feed reads it. |
controller | TimelineController | Focuses an event from anywhere. Create one with createTimelineController(). | |
render | ReactElement, (props, state) => ReactNode | Renders your own element. | |
className | string | Classes for the root. |
The root has data-orientation and, for a busy feed, data-busy. It also sets a --timeline-count CSS variable with the number of events.
TimelineItem
One event. Renders a div with role="listitem", or role="article" in a feed.
| Prop | Type | Default | Description |
|---|---|---|---|
status | "complete", "current", "upcoming" | Where the event stands in a process. current sets aria-current="step" and takes the tab stop first. | |
value | string | generated | Names the event for the controller's focus(). |
className | string | Classes for the item. |
The item and every part inside it get data-complete, data-current or data-upcoming from its status, plus data-orientation. The first and last items get data-first and data-last, and each item sets a --timeline-index CSS variable.
TimelineMarker
The circle on the line. Shows a dot when empty, or any icon you pass as children. Hidden from screen readers.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | Classes for the marker, such as a size or a color. |
TimelineConnector
The line to the next event. Hidden on the last item and hidden from screen readers.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | Classes for the line. Move it with start-* and top-* when you change the marker size. |
TimelineTitle
The event name. Its id names the item through aria-labelledby.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | Classes for the title. |
TimelineTime
A time element. Pass a machine readable dateTime. It describes the item through aria-describedby.
| Prop | Type | Default | Description |
|---|---|---|---|
dateTime | string | The date or time in a machine readable format, like 2026-11-20. | |
className | string | Classes for the time. |
TimelineDescription
Extra text for the event. It also describes the item through aria-describedby.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | Classes for the description. |
createTimelineController
const [controller] = React.useState(() => createTimelineController());
<Timeline aria-label="Activity" controller={controller}>...</Timeline>;
controller.focus("approved");
controller.focus();
focus(value) moves focus to the event with that value. Without a value, it focuses the event that holds the tab stop.
Keyboard
| Key | Action |
|---|---|
Tab | Moves focus into the timeline, to the current event or the first one. |
ArrowDown, ArrowUp | Moves to the next or previous event in a vertical timeline. |
ArrowRight, ArrowLeft | Moves to the next or previous event in a horizontal timeline. Flips in right to left layouts. |
Home, End | Moves to the first or last event. |
PageDown, PageUp | In a feed, moves to the next or previous article from anywhere inside one. |
Accessibility
- The root is a list and each event a list item, or a feed of articles with
feed. In a feed, each article reads its position, such as "2 of 4". - Each event is named by its
TimelineTitleand described by itsTimelineTimeandTimelineDescription. - The
currentevent hasaria-current="step". Markers and connectors arearia-hidden. - Only one event is in the tab order at a time, so a long timeline is a single
Tabstop. - Always give the timeline a name with
aria-labeloraria-labelledby. A feed without a name logs a warning in development.
For AI Agents
When to use
- Activity logs, audit trails and changelogs, ordered by time.
- Progress of a process that already happened or is in motion, such as order tracking or deployment status, with
status. - Roadmaps and milestones in a row, with
orientation="horizontal". - Infinite lists of updates, with
feedandbusy.
When not to use
- A form or wizard the user moves through step by step. Use a Stepper.
- A plain list with no order in time. Use a normal list or a Table.
- Chat messages. Use the Chat UI blocks.
Agent notes
- Import from
@/components/ui/timeline. The exports areTimeline,TimelineItem,TimelineMarker,TimelineConnector,TimelineTitle,TimelineTime,TimelineDescription,createTimelineControllerand theTimelineStatustype. - Set
statusonTimelineItemonly. The marker, connector, title, time and description read it from the item. - Put
TimelineMarkerandTimelineConnectorinside each item. The item hasps-9(orpt-9when horizontal) to make room for them. - When you change the marker size, move the connector with
start-*andtop-*and the item padding withps-*so the line stays centered. - Always pass
dateTimetoTimelineTimeand anaria-labeltoTimeline. - The file is a client component (
"use client"), but you can render it from a server component as long as you don't pass functions as props.
Resources
- Markdown: /docs/components/timeline.md
- Variants: Timeline components, 6 free examples
- Install:
npx shadcn@latest add @shadcnuikit/timeline1 - MCP: call
get_item_codewithtimeline1from the MCP Server - Full index for agents: llms.txt