Scheduling
Gantt
A project plan that is a real table: tasks with dates, progress and dependencies in columns, and the schedule drawn as bars, milestones and arrows. Tasks move and resize from the keyboard as well as by dragging.
import '@reactloom/scheduler/styles.css';
import { Gantt } from '@reactloom/scheduler';Examples
Release plan
Parent rows show the span of their tasks; dependency arrows run from finish to start. A task that starts before what it depends on finishes is marked, in colour and in text.
import { Gantt, type GanttTask } from '@reactloom/scheduler';
import { useState } from 'react';
const at = (day: number) => new Date(Date.UTC(2031, 2, day));
const plan: GanttTask[] = [
{ id: 'discovery', title: 'Discovery', start: at(3), end: at(7), progress: 1 },
{ id: 'build', title: 'Build', start: at(7), end: at(21) },
{ id: 'api', title: 'API', start: at(7), end: at(14), progress: 0.6, parentId: 'build', dependencies: ['discovery'] },
{ id: 'web', title: 'Web app', start: at(10), end: at(19), progress: 0.3, parentId: 'build', dependencies: ['discovery'], color: 'var(--pl-color-chart-2)' },
{ id: 'qa', title: 'QA', start: at(17), end: at(21), progress: 0, parentId: 'build', dependencies: ['api'], color: 'var(--pl-color-chart-3)' },
{ id: 'launch', title: 'Launch', start: at(24), end: at(24), milestone: true, dependencies: ['qa', 'web'] },
];
// Tab to the grid. On a schedule cell, Alt + ← / → moves the task and Alt + Shift + ← / → changes
// its end; or drag a bar or its end. Moving QA before API finishes marks the conflict in text.
export default function Example() {
const [tasks, setTasks] = useState(plan);
return (
<div style={{ width: '100%' }}>
<Gantt
aria-label="Release plan"
tasks={tasks}
timeZone="UTC"
rangeStart={at(1)}
rangeEnd={at(26)}
dayWidth={28}
onTaskChange={({ task, start, end }) => setTasks((list) => list.map((t) => (t.id === task.id ? { ...t, start, end } : t)))}
/>
</div>
);
}Read-only
Without onTaskChange the chart is a navigable table.
import { Gantt, type GanttTask } from '@reactloom/scheduler';
const at = (day: number) => new Date(Date.UTC(2031, 3, day));
// Without onTaskChange the chart is read-only: a navigable table with a visual schedule.
export default function Example() {
const tasks: GanttTask[] = [
{ id: 'survey', title: 'Site survey', start: at(1), end: at(4), progress: 1 },
{ id: 'permits', title: 'Permits', start: at(4), end: at(12), progress: 0.5, dependencies: ['survey'] },
{ id: 'works', title: 'Ground works', start: at(12), end: at(20), dependencies: ['permits'] },
{ id: 'handover', title: 'Handover', start: at(21), end: at(21), milestone: true, dependencies: ['works'] },
];
return (
<div style={{ width: '100%' }}>
<Gantt aria-label="Site plan" tasks={tasks} timeZone="UTC" dayWidth={22} />
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
tasksrequired{ id, title, start, end, progress?, parentId?, dependencies?, milestone?, color? }. End is exclusive; dependencies are finish-to-start. | GanttTask[] | — |
aria-labelrequired | string | — |
onTaskChangekind 'move' or 'resize'. Update your tasks to apply it; reschedule dependants yourself if you want them to follow. | ({ task, start, end, kind }) => void | — |
onTaskSelectEnter on a schedule cell, or a click on a bar. | (task) => void | — |
timeZoneDays are counted in this IANA time zone. Default: the browser’s. | string | — |
dayWidthWidth of a day in px. | number | 32 |
rangeStart · rangeEndDefault: the tasks’ span with two days either side. | Date | — |
defaultExpandedIdsParents open at first. Default: all. | string[] | — |
heightScroll area. | number | string | — |
messagesTranslate column names, summaries and announcements. | Partial<GanttMessages> | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-align] | present when on |
[data-conflict] | present when on |
[data-dragging] | present when on |
[data-expanded] | present when on |
[data-leaf] | present when on |
[data-milestone] | present when on |
[data-schedule] | present when on |
[data-summary] | present when on |
[data-today] | present when on |
Theme tokens it reads
--pl-color-accent-fg --pl-color-accent-solid --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-subtle --pl-color-danger-solid --pl-color-fg-default --pl-color-fg-muted --pl-focus-ring-color --pl-focus-ring-width --pl-font-size-sm --pl-font-size-xs --pl-radius-md --pl-radius-sm
Accessibility
- The chart is a treegrid: each task is a row with its level, position and expanded state; every column has a header.
- The bars, milestones, today line and arrows are hidden from assistive technology because each schedule cell says the same in text: the dates, progress and any dependency conflict.
- Moves and resizes are announced with the new dates; focus stays on the task.
| Key | Action |
|---|---|
| ← → ↑ ↓ | Move between cells |
| Home / End · Ctrl + Home / End | First / last cell in the row / chart |
| → / ← (task name) | Expand / collapse, or go to the parent |
| Alt + ← / → (schedule) | Move the task a day earlier / later |
| Alt + Shift + ← / → (schedule) | End the task a day earlier / later |
| Enter (schedule) | Select the task |
Usage guidelines
Do
- Keep the plan in your state and decide how dependants follow a move.
- Give milestones a short, distinct name.
Don’t
- Don’t rely on the bar colours alone: put status in the task name or progress.