# Timeline Chart

Timeline chart: a Gantt chart with milestones and a Today line, and an event timeline.

- Category: Charts
- Page: https://wunderui.com/components/timeline-chart
- Tier: Core and Pro

## Install

Timeline Chart ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { TimelineChart, TimelineChartProps, TimelineChartVariant } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
import { TimelineChart } from "@wunderui/react/charts"

const items = [
  { label: "Design", start: 42, end: 46 },
  { label: "API", start: 44, end: 50 },
  { label: "Launch", start: 54, end: 54 },
]

export function LaunchPlan() {
  return <TimelineChart items={items} timeFormatter={(w) => `W${Math.round(w)}`} label="Launch plan" />
}
```

Expected result: Two bars on a week scale and a diamond for the launch, with the task names at the left.

## When to use

### Use Timeline Chart for

- A plan with tasks, durations and milestones (Gantt)
- Events along a time axis, above and below it
- A Today line against a plan

### Use something else

- [Range Bar Chart](https://wunderui.com/components/range-bar-chart) for spans per category without a time axis
- [Timeline](https://wunderui.com/components/timeline) for a vertical list of events in a card
- [Waterfall Chart](https://wunderui.com/components/waterfall-chart) for changes that add up to a total
- [Status Tracker](https://wunderui.com/components/status-tracker) for health per day or per run

## Keyboard

The plot is focusable. Arrow keys walk the items and the live region reads a task as Design: 2 to 6, group Design, and the data table has Start and End (or Date) and a Group column.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge. |
| `ArrowRight` or `ArrowLeft` | Moves to the next or previous item. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one). |
| `Home` or `End` | Jumps to the first or last item. |
| `Escape` | Clears the active point. |
| `Enter` or `Space` | On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on. |

## Behavior

What the chart does on its own and what the page decides.

- **Items:** Each item has a label and either a start and end (a Gantt bar) or a time (an event), plus an optional caption and group. An item whose start equals its end is a diamond milestone.
- **Scale:** Positions are numbers on a round scale across the range of the items, or a fixed range, formatted by your formatter. Today draws a labelled Today line.
- **Events:** In the event timeline, events sit on stems above and below the axis, alternating, so their labels don't collide.
- **Bad times:** Items without valid times are skipped before the chart decides whether it is empty.
- **Loading, empty and error:** The chart keeps its size while it loads, is empty or fails, so the card never jumps. Loading shows a muted shimmer, and an error shows a Try again button when you add a retry handler.
- **Legend:** A ChartCard shows the series as badges. With two or more series each badge switches its series off and the last visible one stays on, and a legend of roles instead of series can be made static.
- **Size:** The chart fills the width of its container, and you set the plot height. Text never scales, so labels keep their size at every width.

## Motion

The enter sequence and the hover follow the library's motion tokens.

- **Grow:** Bars grow from their start and stems out of the axis, then milestones and event dots land, the first time the chart is in view, after loading, on a key change or when new items arrive. A parent re-render with the same items does not replay it. You can turn it off.
- **Hover:** The item in focus keeps its strength and the others dim to --chart-dim.
- **Reduced motion:** With reduced motion the enter sequence is off and the chart appears at once. The tooltip, the hover dimming and every state still work.

## Anatomy

- `TimelineChart`: Takes the items (label, start and end for Gantt, a time for events, plus an optional caption and group), groups for colours and legend, a Today marker, a fixed range and a label formatter.
- `Plot`: The focusable region. Arrow keys walk its marks and the live region reads each one the way the tooltip shows it.
- `Marks`: Bars that grow from their start, and an item whose start equals its end becomes a diamond milestone that lands after the bars. Events sit on stems above and below the axis: the stem grows out of the axis first, then the dot lands and the texts follow. The item in focus keeps its strength and the others dim.
- `Time axis`: Ticks on a round scale across the range of the items (or a fixed range), formatted by your label formatter, with a dashed grid. Today is the dashed marker of the cartesian charts with its label beside the line.
- `Task labels`: On Gantt, the task names in a column at the left, as wide as the longest name.
- `Tooltip`: The label with its time range (or the event time) and its group.
- `Loading, empty and error`: Muted bars under the shimmer. Items without valid times are skipped before the chart decides whether it is empty.
- `Data table and live region`: A table of the items and their times for screen readers.
- `Chart Grid`
- `Chart Today`

## Best practices

### When to use

- Use it for schedules and sequences: project plans, release calendars, incident history. For values over time use LineChart.

### Do

- Use one numeric scale and a formatter that makes it readable, such as week numbers, month names or dates. The axis labels are the only date context.
- Set Today on planning charts so progress reads against the present, and group tasks by team.
- Keep Gantt to about 15 rows per chart. Past that, split by team or phase so each 44 px row stays readable.

### Don't

- Don't draw dependencies the chart doesn't know. Arrows between tasks aren't part of it, so mention a blocking task in the label.
- Don't use the event timeline for more than about ten events. Labels that alternate above and below will overlap.

## API reference

### TimelineChart

| Prop | Type | Default | Description |
|---|---|---|---|
| items* | readonly TimelineItem[] |  |  |
| activeIndex | number \| null |  | The active point (hovered or focused) as an index into `data`, to control it yourself. `null` shows none. |
| animate | boolean |  |  |
| animationKey | string \| number |  |  |
| className | string |  | Extra classes for the root element of the chart. |
| defaultActiveIndex | number \| null |  | The point that is active at first, for an uncontrolled chart. It shows the tooltip without a pointer. |
| description | string |  |  |
| domain | readonly [number, number] |  | Visible range (default: the items' range). |
| groups | readonly { key: string; label?: string; color?: ChartColor }[] |  | Groups in legend order with colours (team, kind of event). |
| height | number |  |  |
| hiddenSeries | readonly string[] |  |  |
| label | string |  |  |
| onActiveIndexChange | (index: number \| null) => void |  | Called with the index when the pointer or the arrow keys move to another point, and with `null` when they leave. Use it to show the hovered value in a headline. |
| onRetry | () => void |  | Shows a Try again button in the error state and calls this when it is pressed. |
| state | "ready" \| "loading" \| "empty" \| "error" |  |  |
| timeFormatter | (v: number) => string |  | Formats a position on the time scale, e.g. (w) => `W${w}` or a date. |
| today | number |  | A "Today" line on the scale. |
| todayLabel | string | "Today" |  |
| variant | "gantt" \| "event-timeline" | "gantt" | Figma variant. Default `gantt`. |
| width | number |  |  |

## Examples

### States

## In context

### Launch Plan

Weeks of the launch with today's position.

## For AI agents

`get_component("timeline-chart")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
