A Gantt chart for one day or any span of hours. Each row shows the planned interval and the actual one as two bars of different weight. The server computes every bar, groups collapse on native <details>, and chosen intervals such as off hours get hatched. The only client part is the live "now" line. On narrow screens the scale scrolls sideways while the name column stays put.
Browser Support
Expands and collapses task groups.
Mixes the group label background.
Preview
Click a group header to collapse it, this works without JavaScript. The "now" line follows your local clock and appears after the page loads.
Night jobs2
Daytime2
Evening2
Installation
Usage
import { GanttChart } from "@/components/ui/gantt-chart"
const h = (hours: number, minutes = 0) => hours * 60 + minutes
export default function Example() {
return (
<GanttChart
shaded={[[0, h(7)], [h(23), h(24)]]}
items={[
{ id: "backup", label: "Database backup", group: "Night", planned: [h(2), h(3)], actual: [h(2, 5), h(3, 20)], status: "done" },
{ id: "reports", label: "Daily reports", group: "Day", planned: [h(8), h(9)], actual: [h(8, 40), h(10, 10)], status: "delayed" },
{ id: "digest", label: "Email digest", planned: [h(18), h(18, 30)], status: "planned" },
]}
/>
)
}Examples
Range with Date objects
When start is a Date, Date values in items are measured from it. timeZone and locale control the labels, and a fixed now pins the line without any client code. Set timeZone: the chart is computed on the server, and without it Dates are read in the server zone.
const at = (hh: number, mm = 0) => new Date(Date.UTC(2026, 10, 23, hh, mm))
<GanttChart
start={at(8)}
end={at(20)}
timeZone="UTC"
tickStep={120}
now={at(13, 15)}
shaded={[[at(12), at(13)]]}
labels={{ name: "Station", shaded: "Break" }}
items={[
{ id: "a", label: "Assembly", planned: [at(8), at(12)], actual: [at(8, 10), at(11, 50)] },
{ id: "b", label: "Painting", planned: [at(10), at(15)], actual: [at(10, 30), at(13, 15)] },
{ id: "c", label: "Packing", planned: [at(14), at(19)] },
]}
/>Fact only, collapsed group
Rows may have only planned or only actual. defaultCollapsed renders groups closed, and now={null} hides the line and drops the client part.
Night jobs2
Daytime2
<GanttChart
now={null}
tickStep={180}
defaultCollapsed={["night"]}
showLegend={false}
groups={[
{ id: "night", label: "Night jobs" },
{ id: "day", label: "Daytime" },
]}
items={[
{ id: "backup", label: "Database backup", group: "night", actual: [120, 195] },
{ id: "reports", label: "Daily reports", group: "day", actual: [510, 600] },
]}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | GanttItem[] | - | Rows: id, label, group, planned and actual intervals, status |
| start | number | Date | 0 | Range start: minutes or a Date |
| end | number | Date | 1440 | Range end: minutes or a Date |
| groups | { id: string; label: string }[] | - | Group titles and order |
| defaultCollapsed | string[] | - | Group ids rendered closed |
| tickStep | number | 60 | Tick step in minutes |
| now | "auto" | number | Date | null | "auto" | "auto" follows the clock, a time pins the line, null hides it |
| shaded | [number | Date, number | Date][] | - | Hatched intervals |
| locale | string | "en-US" | Locale for time labels with a Date range |
| timeZone | string | - | IANA time zone for reading Dates and labels. Without it the server zone is used |
| rowHeight | number | 36 | Row height in px |
| labelWidth | number | 200 | Width of the name column in px |
| minTimelineWidth | number | 640 | Scale width at which horizontal scroll starts, px. Tick labels are thinned for it |
| showLegend | boolean | true | Show the legend |
| labels | { name?; planned?; actual?; now?; shaded?; status? } | - | Column, legend and status texts |
| className | string | - | Additional CSS classes |
Features
- Minutes or Dates: numbers are minutes from the range start, Dates are measured from a Date start
- Plan and fact: a light dashed bar for the plan and a solid thin bar for the fact
- Groups on <details>: headers collapse rows without JavaScript and show the overall span
- Now line: the only client part: with now="auto" it follows the clock after mount
- Sticky names: the name column stays in place while the scale scrolls
- Screen readers: every row has hidden text with its intervals
type GanttItem = {
id: string
label: string
group?: string
planned?: [number | Date, number | Date]
actual?: [number | Date, number | Date]
status?: "planned" | "running" | "done" | "delayed" | "failed"
}