Gantt Pro
A project's tasks on a timeline: bars from start to end with the done part filled in, milestones as diamonds, arrows from each task to those waiting on it, weekends shaded and a dashed line at today. Drag a bar to move it or its end to stretch it, in whole days, with a live preview. Days, weeks or months across, with the task names beside.
import { Gantt } from '@patine-ui/pro';
<Gantt tasks={tasks} onTasksChange={setTasks} style={{ width: '100%' }} />
Try the props
design<Gantt tasks={tasks} onTasksChange={setTasks} />
Example: an office move
An office move planned by the week: tasks depend on each other, the list shows who owns each, and pressing a bar shows its dates. Drag a bar to reschedule it.
<View style={{ width: '100%', gap: 8 }}> <Gantt tasks={tasks} onTasksChange={setTasks} defaultScale="week" onTaskPress={(t) => setPicked(`${t.name}: ${t.start.toLocaleDateString()} – ${t.end.toLocaleDateString()}`)} /> <Text size="sm" color="textSecondary">{picked || 'Press a bar for its dates.'}</Text> </View>
Tasks
A task is { id, name, start, end, progress?, dependencies?, color?, milestone?, assignee?, locked?, data? }. end is the last day, included. A milestone is a single day drawn as a diamond. dependencies lists the tasks that must finish first, drawn as arrows from their end into this task's start.
Editing
onTasksChange(tasks, change) gets the new tasks after each move: set them as tasks, or use defaultTasks. onTaskChange(change) is the place to save: { task, start, end, kind }, where kind is 'move' or 'resize'. editable={false} makes the chart read-only; a locked task stays put. A tap opens a task with onTaskPress.
Scales
scale is 'day', 'week' or 'month' (controlled with onScaleChange, or defaultScale), with a switch above unless showScaleSwitch={false}. columnWidth sets a column's width. The range is the tasks' span padded by the scale; startDate and endDate fix it.
<Gantt tasks={roadmap} defaultScale="month" editable={false} listWidth={180} style={{ width: '100%' }} />
Accessibility
Each bar is a button read as "Build, Mar 9 to Mar 20, 40% done" (or "Launch, milestone, Mar 23"), with a hint on how to move it. Dragging needs a pointer, so the same moves are screen-reader actions (a day earlier or later, a day shorter or longer) and, on the web, arrow keys and Shift + arrow keys on the focused bar.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tasks / defaultTasks | GanttTask[] | [] | See Tasks. |
onTasksChange | (tasks, change) => void | — | |
onTaskChange | (change) => void | — | |
onTaskPress | (task) => void | — | |
scale / defaultScale / onScaleChange | 'day' | 'week' | 'month' | 'day' | |
showScaleSwitch | boolean | true | |
columnWidth | number | day 40, week 96, month 140 | |
rowHeight | number | 44 | |
showList / listWidth | boolean / number | true / 200 | Task names beside the chart. |
editable | boolean | true | Drag and keys. |
showDependencies / showProgress | boolean | true | |
startDate / endDate | Date | the tasks' span | |
now / locale | |||
renderBarLabel | (info) => ReactNode | — | |
loading / error / onRetry / emptyTitle / renderEmpty | States. | ||
density / labels / design / theme / accessibilityLabel / style |
Time runs left to right in every language for now.