Timeline Chart
Timeline chart: a Gantt chart with milestones and a Today line, and an event timeline.
Playground
Installation
Timeline Chart comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
TimelineChart,
TimelineChartProps,
TimelineChartVariant,
} from "@wunderui/react/charts"Then use it:
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 for
- Range Bar Chart for spans per category without a time axis
- Timeline for a vertical list of events in a card
- Waterfall Chart for changes that add up to a total
- Status Tracker for health per day or per run
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
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.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- 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).
- HomeorEnd
- Jumps to the first or last item.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
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 the first time the chart is in view, and again after loading, on a key change or when new items arrive. You can turn it off.
- Reduced motion
- With reduced motion the enter sequence is off and the chart appears at once. The tooltip, crosshair and every state still work.
Anatomy
TimelineChart plots items on a numeric time scale: a Gantt chart of task bars and milestones, or an event timeline above and below an axis. Positions are numbers such as days, weeks or timestamps.
Launch plan
| label | Start | End | Group |
|---|---|---|---|
| Discovery | W40 | W43 | Product |
| Design | W42 | W46 | Design |
| API | W44 | W50 | Engineering |
| Web app | W46 | W52 | Engineering |
| QA | W51 | W54 | Quality |
| Launch | W54 | W54 | Product |
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.
- data-slot="chart-plot"
The focusable region. Arrow keys walk its marks and the live region reads each one the way the tooltip shows it.
- data-slot="chart-marks"
Bars that grow from their start, and an item whose start equals its end becomes a diamond milestone. Events sit on stems above and below the axis, alternating.
Ticks on a round scale across the range of the items (or a fixed range), formatted by your label formatter, plus a Today line when set.
On Gantt, the task names in a column at the left, as wide as the longest name.
- data-slot="chart-tooltip"
The label with its time range (or the event time) and its group.
- data-slot="chart-message"
Muted bars under the shimmer. Items without valid times are skipped before the chart decides whether it is empty.
A table of the items and their times for screen readers.
Best practices
- 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.
- Do
Set Today on planning charts so progress reads against the present, and group tasks by team.
- Do
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
Don't use the event timeline for more than about ten events. Labels that alternate above and below will overlap.
API reference
One table for TimelineChart. It is a plain component, so the table lists every prop, and the ChartCard around it takes its own props and works without one.
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.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("timeline-chart")The full library index for assistants is at /llms.txt.