---
title: "Timeline"
description: "A draggable timeline of dated events around a focused card."
category: "Components"
publishedAt: "2026-10-20"
updatedAt: "2026-11-10"
documentation: "https://beui.dev/components/motion/timeline"
markdown: "https://beui.dev/components/motion/timeline.md"
license: "MIT"
---

# Timeline

> A draggable timeline of dated events around a focused card.

## Install

```bash
npx shadcn@latest add @beui/timeline
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"use client";

import { Heart } from "lucide-react";
import { Timeline, type TimelineEvent } from "@/components/motion/timeline";

function Likes({ count }: { count: string }) {
  return (
    <>
      <Heart aria-hidden="true" className="size-4" />
      <span>{count}</span>
    </>
  );
}

function ChartMedia({ points }: { points: number[] }) {
  const max = Math.max(...points);
  const path = points
    .map((p, i) => {
      const x = (i / (points.length - 1)) * 100;
      const y = 56 - (p / max) * 44;
      return `${i === 0 ? "M" : "L"}${x.toFixed(1)} ${y.toFixed(1)}`;
    })
    .join(" ");
  return (
    <svg
      viewBox="0 0 100 64"
      preserveAspectRatio="none"
      className="size-full text-foreground"
      role="img"
      aria-label="Rising line chart"
    >
      <path d={`${path} L100 64 L0 64 Z`} className="fill-foreground/[0.06]" />
      <path
        d={path}
        fill="none"
        stroke="currentColor"
        strokeWidth="1.5"
        vectorEffect="non-scaling-stroke"
      />
    </svg>
  );
}

function PhoneMedia() {
  return (
    <div className="flex size-full items-end justify-center bg-muted/40 pt-5">
      <div className="flex h-full w-1/2 flex-col gap-2 rounded-t-3xl border border-b-0 border-border bg-background p-3">
        <div className="mx-auto h-1.5 w-8 rounded-full bg-foreground/15" />
        <div className="h-3 w-2/3 rounded-full bg-foreground/15" />
        <div className="h-16 rounded-xl bg-foreground/[0.06]" />
        <div className="h-2 w-full rounded-full bg-foreground/10" />
        <div className="h-2 w-4/5 rounded-full bg-foreground/10" />
      </div>
    </div>
  );
}

function SyncMedia() {
  return (
    <div className="flex size-full items-center justify-center gap-3 bg-muted/40 p-5">
      <div className="flex h-full flex-1 flex-col gap-2 rounded-xl border border-border bg-background p-3">
        <div className="flex gap-1">
          <span className="size-1.5 rounded-full bg-foreground/20" />
          <span className="size-1.5 rounded-full bg-foreground/20" />
          <span className="size-1.5 rounded-full bg-foreground/20" />
        </div>
        <div className="h-2 w-3/4 rounded-full bg-foreground/15" />
        <div className="h-2 w-full rounded-full bg-foreground/10" />
        <div className="h-2 w-2/3 rounded-full bg-foreground/10" />
      </div>
      <div className="flex h-4/5 w-1/4 flex-col gap-2 rounded-2xl border border-border bg-background p-2">
        <div className="h-2 w-3/4 rounded-full bg-foreground/15" />
        <div className="h-2 w-full rounded-full bg-foreground/10" />
        <div className="h-2 w-2/3 rounded-full bg-foreground/10" />
      </div>
    </div>
  );
}

function GridMedia() {
  return (
    <div className="grid size-full grid-cols-3 gap-2 bg-muted/40 p-4">
      {Array.from({ length: 6 }, (_, i) => (
        <div
          // biome-ignore lint/suspicious/noArrayIndexKey: static decoration
          key={i}
          className="rounded-2xl border border-border bg-background"
          style={{ opacity: 1 - i * 0.1 }}
        />
      ))}
    </div>
  );
}

function KeysMedia() {
  return (
    <div className="flex size-full flex-col items-center justify-center gap-3 bg-muted/40">
      <div className="flex gap-1.5">
        {["⌘", "K"].map((key) => (
          <kbd
            key={key}
            className="flex size-11 items-center justify-center rounded-xl border border-border bg-background font-sans text-foreground text-lg shadow-sm"
          >
            {key}
          </kbd>
        ))}
      </div>
      <div className="h-2 w-28 rounded-full bg-foreground/10" />
    </div>
  );
}

function ReleaseMedia() {
  return (
    <div className="flex size-full items-center justify-center bg-primary text-primary-foreground">
      <span className="font-medium text-5xl tracking-tighter">2.0</span>
    </div>
  );
}

const EVENTS: TimelineEvent[] = [
  {
    id: "beta",
    date: "2025-06-12",
    title: "Private beta opens",
    media: <GridMedia />,
    meta: <Likes count="1,204" />,
  },
  {
    id: "android",
    date: "2025-08-03",
    title: "Lumen for Android",
    media: <PhoneMedia />,
    meta: <Likes count="3,918" />,
  },
  {
    id: "offline",
    date: "2025-10-14",
    title: "Offline drafts",
    media: <SyncMedia />,
    meta: <Likes count="4,827" />,
  },
  {
    id: "signups",
    date: "2025-11-20",
    title: "Weekly signups double",
    media: <ChartMedia points={[4, 5, 4, 6, 5, 7, 6, 9, 8, 12, 11, 15]} />,
    meta: <Likes count="6,175" />,
  },
  {
    id: "spaces",
    date: "2026-01-09",
    title: "Shared spaces",
    media: <GridMedia />,
    meta: <Likes count="2,640" />,
  },
  {
    id: "command",
    date: "2026-03-17",
    title: "The command menu",
    media: <KeysMedia />,
    meta: <Likes count="5,302" />,
  },
  {
    id: "rank",
    date: "2026-05-28",
    title: "Top 10 in productivity",
    media: <ChartMedia points={[3, 4, 6, 5, 8, 9, 8, 11, 13, 12, 14, 16]} />,
    meta: <Likes count="13,916" />,
  },
  {
    id: "two",
    date: "2026-08-05",
    title: "Lumen 2.0",
    media: <ReleaseMedia />,
    meta: <Likes count="27,130" />,
  },
];

export function TimelinePreview() {
  return (
    <div className="w-full py-6">
      <Timeline
        events={EVENTS}
        defaultValue="signups"
        aria-label="Lumen release history"
      />
    </div>
  );
}
```

## API Reference

### Timeline

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `events` | `TimelineEvent[]` |  | Yes | The events, each shown as a card along the timeline. |
| `value` | `string` |  | No | Focused event id (controlled). |
| `defaultValue` | `string` |  | No | Initially focused event id (uncontrolled). Defaults to the first event. |
| `onValueChange` | `((id: string) => void)` |  | No | Called with the event id when a different event comes into focus. |
| `itemWidth` | `number` | `340` | No | Card width in px at full size. Shrinks to fit narrow containers. |
| `height` | `number` | `600` | No | Stage height in px. |
| `years` | `boolean` | `true` | No | Large year numerals drifting behind the cards. |
| `ruler` | `boolean` | `true` | No | A group of ticks in each gap between cards. |
| `cables` | `boolean` | `true` | No | Lines fanning from the top and bottom center to the cards near the center. |
| `formatDate` | `((date: Date) => string)` |  | No | Formats the date on each card. Defaults to a short date like "Mar 4 ’24". |
| `formatYear` | `((date: Date) => string)` |  | No | Formats the large year numerals. Defaults to a 2-digit year like "’24". |
| `aria-label` | `string` |  | No | Accessible name for the timeline. Default: "Timeline" |
| `labels` | `Partial<{ label: string; hint: string; }>` |  | No | Override any built-in string. |
| `className` | `string` |  | No | Classes merged onto the root element. |

## Types

### TimelineEvent

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Stable identity, used for `value` and React keys. |
| `date` | `string \| Date` | Yes | ISO date string or Date. Read in UTC. |
| `title` | `string` | Yes | Card heading under the date, cut to 1 line. |
| `media` | `ReactNode` | No | Visual shown inside the card. Keep it non-interactive: the card itself is the button. |
| `meta` | `ReactNode` | No | Footer line under the media: a stat, a tag, a reaction count. |

## About Timeline

Timeline is an animated horizontal React timeline for dated events, built with Framer Motion and Tailwind CSS. The event at the center of the track is shown at full size while its neighbours shrink and dim, a group of ticks sits in each gap between cards and each year's numeral drifts past on a slower parallax layer. Drag the track with momentum, swipe a trackpad sideways, click a card or use the arrow keys, and the nearest event springs to the center.

### When to use it

- A product or company page tells its story as a run of dated milestones, releases or launches.
- A changelog or release history wants a browsable visual summary above the full notes.
- A portfolio or case study walks through a project's phases with a screenshot for each step.

### Accessibility

The timeline is a labelled region and each event is a native button named by its date and title, with media left outside the button so it stays readable. The events keep one roving tab stop on the centered event, marked with aria-current, and Arrow Left, Arrow Right, Home and End move focus and the track together. Vertical wheel and touch scrolling stay with the page. With reduced motion enabled, the glide spring is skipped and the track jumps straight to the chosen event.

### FAQ

**How do I build a horizontal timeline in React?**

Install the component and pass an events array to Timeline. Each event needs an id, a date and a title, and can carry media for the card and a meta line such as a reaction count or tag.

**How do I know which event is centered?**

Pass onValueChange to receive the centered event's id as the track moves, and defaultValue to pick the starting event. Pass value to control it from your own state.

**Can I change how dates and years are shown?**

Yes. formatDate formats the label above each card and formatYear formats the large background numeral. Dates are read in UTC, so an ISO date string shows the same day everywhere. Set years={false}, ruler={false} or cables={false} to hide any of the background layers.

## Source

- Registry detail: https://beui.dev/r/timeline
- Raw source: https://beui.dev/r/timeline/raw
- GitHub: https://github.com/starc007/ui-components
