# 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.

- Kind: Component (Charts)
- Docs: https://ui.minidev.pro/docs/gantt-chart
- Source (registry JSON with the full file): https://ui.minidev.pro/r/gantt-chart.json
- License: MIT. One file, yours to edit after install.

## 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`](https://ui.minidev.pro/docs/gantt-row); for calendar events by the hour use [`EventCalendar`](https://ui.minidev.pro/docs/event-calendar); for request spans use [`TraceWaterfall`](https://ui.minidev.pro/docs/trace-waterfall).

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/gantt-chart
```

Writes `components/ui/gantt-chart.tsx` plus the MiniDev files it is built from (segmented-control) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/gantt-chart.json`.

### npm package

```bash
npm i minidev-ui-kit
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { GanttChart } from "@/components/ui/gantt-chart"
```

From the npm package:

```tsx
import { GanttChart } from "minidev-ui-kit/ui/gantt-chart"
```

## Usage

```tsx
import { GanttChart } from "@/components/ui/gantt-chart"

export function Example() {
  return (
    <GanttChart />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `tasks` | `GanttTask[]` | - | no | Tasks to plot. Defaults to a six week Lumen launch plan built around today. |
| `scale` | `GanttScale` | - | no | Controlled zoom level. |
| `defaultScale` | `GanttScale` | `"day"` | no | Initial zoom level when uncontrolled. |
| `onScaleChange` | `(scale: GanttScale) => void` | - | no | Called when the Day/Week control changes the scale. |
| `today` | `Date \| string` | - | no | The date the today line marks. Defaults to the current date. |
| `padDays` | `number` | `2` | no | Empty days drawn before the first and after the last task. |
| `title` | `string` | `"Launch plan"` | no | Heading above the chart. Empty hides the header row. |
| `nameWidth` | `number` | `176` | no | Width of the sticky task column in px. |
| `onTaskClick` | `(task: GanttTask) => void` | - | no | Called when a bar is clicked or activated with the keyboard. |
| `className` | `string` | - | no |  |

## Examples

### Week scale

defaultScale="week" zooms out to 16px per day for plans that run over a quarter.

```tsx
<GanttChart defaultScale="week" />
```

### Fixed dates

Tasks take ISO day strings, group under a heading, and today pins the marker so the chart looks the same every day.

```tsx
const tasks: GanttTask[] = [
  { id: "kickoff", name: "Kickoff and access", start: "2026-10-05", end: "2026-10-07", progress: 100, group: "Onboarding" },
  { id: "import", name: "Import customers", start: "2026-10-08", end: "2026-10-14", progress: 60, group: "Onboarding", dependsOn: ["kickoff"] },
  { id: "sso", name: "SSO setup", start: "2026-10-12", end: "2026-10-16", progress: 20, group: "Onboarding", dependsOn: ["kickoff"] },
  { id: "training", name: "Finance team training", start: "2026-10-19", end: "2026-10-21", group: "Rollout", dependsOn: ["import", "sso"] },
  { id: "golive", name: "Go live", start: "2026-10-26", end: "2026-10-27", group: "Rollout", dependsOn: ["training"], tone: "success" },
]

<GanttChart tasks={tasks} today="2026-10-14" title="Northwind onboarding" />
```

### Task click

onTaskClick fires for a click or Enter on a bar; an empty title drops the header and nameWidth trims the task column.

```tsx
function TaskClickDemo() {
  const [task, setTask] = React.useState<GanttTask | null>(null)
  return (
    <div className="flex w-full max-w-4xl flex-col gap-3">
      <GanttChart title="" nameWidth={150} onTaskClick={setTask} />
      <p className="text-xs text-fg-muted">{task ? task.name + ": " + (task.progress ?? 0) + "% done" : "Click a bar, or tab to one and press Enter."}</p>
    </div>
  )
}
```

## 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. |
| `Enter` or `Space` | On a bar, calls `onTaskClick` with that task. |
| `Escape` | On a bar, hides the tooltip without moving focus. |
| `ArrowLeft` or `ArrowRight` | In the Day/Week switch, changes the scale. |

## Accessibility

- Each bar is a `<button>` with a full `aria-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-US` locale.

## FAQ

### 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`](https://ui.minidev.pro/docs/dialog) or [`Sheet`](https://ui.minidev.pro/docs/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.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- Built from: [segmented-control](https://ui.minidev.pro/docs/segmented-control/md)

## Related

- [Gantt Row](https://ui.minidev.pro/docs/gantt-row/md): One row of a Gantt timeline: a task label beside a track with a bar placed by start and end values on a shared scale. Stack rows to build a React roadmap.
- [Event Calendar](https://ui.minidev.pro/docs/event-calendar/md): React week and day event calendar: events placed by time, side by side overlaps, an all-day row, a live time line and click or keyboard to create events.
- [Trace Waterfall](https://ui.minidev.pro/docs/trace-waterfall/md): React trace waterfall that draws each span as a bar offset by start time and scaled by duration, indented by depth with a millisecond label for observability.
- [Area Chart](https://ui.minidev.pro/docs/area-chart/md): Dependency free SVG area chart for React with a smoothed line, dashed grid, gradient fill and an optional highlighted point. Strokes stay crisp at any size.
- [Bar Chart](https://ui.minidev.pro/docs/bar-chart/md): Lightweight React bar chart with rounded bars, dashed gridlines and labels. Hovering a bar dims the rest and shows its value; the peak is highlighted first.
- [Chart Card](https://ui.minidev.pro/docs/chart-card/md): Card wrapper for charts with a title, optional description and a minimum height body. Pairs with the area, bar and donut charts in a React dashboard.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
