Gantt Chart
React Gantt chart for project timelines with day and week scales, a today line, progress fills, dependency arrows, a fixed task column and focusable bars.
Installation
npx shadcn@latest add @minidev/gantt-chart
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/gantt-chart.json
Usage
import { GanttChart } from "@/components/ui/gantt-chart"
export function Example() {
return (
<GanttChart />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| tasksTasks to plot. Defaults to a six week Lumen launch plan built around today. | GanttTask[] | - |
| scaleControlled zoom level. | GanttScale | - |
| defaultScaleInitial zoom level when uncontrolled. | GanttScale | "day" |
| onScaleChangeCalled when the Day/Week control changes the scale. | (scale: GanttScale) => void | - |
| todayThe date the today line marks. Defaults to the current date. | Date | string | - |
| padDaysEmpty days drawn before the first and after the last task. | number | 2 |
| titleHeading above the chart. Empty hides the header row. | string | "Launch plan" |
| nameWidthWidth of the sticky task column in px. | number | 176 |
| onTaskClickCalled when a bar is clicked or activated with the keyboard. | (task: GanttTask) => void | - |
| className | string | - |
When to use
Use for launch plans and delivery schedules. Tasks take Date objects or ISO day strings; end is inclusive. Tasks with the same group share a heading and colour; dependsOn draws arrows. For a single plain bar row use GanttRow; for calendar events by the hour use EventCalendar; for request spans use TraceWaterfall.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Moves focus to the Day/Week switch (shown only when title is not empty), then through every task bar in order. Focusing a bar shows its tooltip. |
| EnterorSpace | On a bar, calls onTaskClick with that task. |
| Escape | On a bar, hides the tooltip without moving focus. |
| ArrowLeftorArrowRight | In the Day/Week switch, changes the scale. |
Accessibility
- Each bar is a
<button>with a fullaria-label, such as "Checkout flow, Nov 10 to Nov 20, 11 days, 0% done, Engineering". - The tooltip is
role="tooltip"and repeats what the label already says, so it does not need to be announced. - Dependency arrows, the today line, weekend shading and the grid are
aria-hidden. Dependencies are not in the bar's label, so list them in your task details if they matter. - Dates are formatted with the
en-USlocale.
Frequently asked questions
Can I drag GanttChart bars to reschedule tasks?
No. Bars are buttons, not drag handles: clicking one or pressing Enter calls onTaskClick(task). Open an edit Dialog or Sheet from there and pass the updated tasks back in.
Why is my task off by a day?
Check end: it is inclusive, so a task from "2026-11-02" to "2026-11-02" is one day long. A string that starts with YYYY-MM-DD is read as that local calendar day, even if a time follows, so time zones do not shift it. A Date keeps its local calendar day.
How do I avoid a hydration mismatch with the today line?
today defaults to the date when the component mounts, and with no tasks the demo plan is built around it. In a Server Component page, pass a fixed today (and your own tasks) so the server and browser draw the same range.
How do I control the Day and Week zoom?
Uncontrolled, it starts at defaultScale ("day"). To control it, pass scale and update it in onScaleChange. Each change scrolls the timeline so today sits about a third of the way in.
Dependencies
npm
Built from
Examples
Week scale
defaultScale="week" zooms out to 16px per day for plans that run over a quarter.
Fixed dates
Tasks take ISO day strings, group under a heading, and today pins the marker so the chart looks the same every day.
Task click
onTaskClick fires for a click or Enter on a bar; an empty title drops the header and nameWidth trims the task column.