Gantt Schedule
A controlled project schedule with real dates, task hierarchy, milestones, finish-to-start dependencies and editable drafts. Save explicitly, review conflicts and retry without losing edits.
This demo saves to local React state. In your application, persist the transaction and update controlled tasks before resolving onCommit. Drag a bar, use Alt + Left/Right, or select a task to edit its dates.
All changes saved
Select a task to inspect or edit dates. Up and Down navigate tasks; Home and End navigate the first and last task. Use Alt plus Left or Right on a task bar to move one calendar day. Use the date form to resize. Escape cancels a drag.
Select a task to edit beside the timeline. Narrow containers open a details drawer. Apply entered values to the draft, then use the persistent Save schedule action to persist changes. Field errors appear beside the input. Drag the task column divider or use its arrow keys to resize; View settings contains working-day snapping and a width slider. Task-bar resize handles also support Left and Right. Drag previews show inclusive dates and the timeline scrolls when you reach either edge.
Editable schedule example
A complete client component with hierarchy, dependencies, a milestone and working days. This example saves to local React state. Date ends are exclusive: October 5–9 uses end: 2026-10-10. The editor displays the inclusive last day. Task details, responsive width and the Apply to draft / Save schedule flow are built in.
"use client";
import { useState } from "react";import { GanttSchedule, applyGanttChangeSet, type GanttTask, type GanttDependency,} from "@flabbergasted-ai/react";
const initialTasks: GanttTask[] = [ { id: "project", name: "Release planning", kind: "summary", start: "2026-10-05", end: "2026-10-30", }, { id: "design", parentId: "project", name: "Design review", start: "2026-10-05", end: "2026-10-10", progress: 60, status: "In progress", assignee: "Morgan", }, { id: "build", parentId: "project", name: "Implementation", start: "2026-10-12", end: "2026-10-29", progress: 0, status: "Planned", assignee: "Alex", }, { id: "release", parentId: "project", name: "Release milestone", kind: "milestone", start: "2026-10-30", end: "2026-10-30", },];
const dependencies: GanttDependency[] = [ { id: "design-build", predecessorId: "design", successorId: "build", type: "FS" }, { id: "build-release", predecessorId: "build", successorId: "release", type: "FS" },];
export default function ProjectSchedule() { const [tasks, setTasks] = useState(initialTasks);
return ( <GanttSchedule tasks={tasks} dependencies={dependencies} today="2026-10-18" calendar={{ workingDays: [1, 2, 3, 4, 5], holidays: ["2026-10-01"] }} initialView="week" height={440} onCommit={(changeSet) => { // Local-state example. The component owns the editable draft; // update controlled tasks only when Save schedule is confirmed. setTasks((current) => applyGanttChangeSet(current, changeSet)); }} /> );}Remote saving example
Implement this API in your application; the docs site does not provide the endpoint. The server must authorize edits and check the revision. Rejecting onCommit preserves the draft and shows the error for retry. Pass your project dependencies and calendar alongside tasks when used.
"use client";
import { useState } from "react";import { GanttSchedule, type GanttTask } from "@flabbergasted-ai/react";
// This example expects a host API that checks expectedRevision atomically,// persists the changes, and returns the canonical tasks and a new revision.export function RemoteSchedule({ projectId, initialTasks, initialRevision }: { projectId: string; initialTasks: GanttTask[]; initialRevision: string;}) { const [schedule, setSchedule] = useState({ tasks: initialTasks, revision: initialRevision, });
return ( <GanttSchedule tasks={schedule.tasks} onCommit={async (changeSet) => { const response = await fetch( "/api/projects/" + encodeURIComponent(projectId) + "/schedule", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ expectedRevision: schedule.revision, changeSet, }), }, ); if (!response.ok) { throw new Error(response.status === 409 ? "The schedule changed on the server. Review the latest version." : "Could not save the schedule. Retry saving."); } const saved: { tasks: GanttTask[]; revision: string } = await response.json(); // Update the controlled data before onCommit resolves. setSchedule(saved); }} /> );}Data and saving contract
Dates are YYYY-MM-DD calendar dates. start is inclusive and end is exclusive. A task covering October 5–9 uses start: 2026-10-05, end: 2026-10-10. The editor displays the inclusive last day. Milestones use kind: milestone with start equal to end. All arithmetic uses UTC day ordinals; locale changes formatting, not task dates.
Keep tasks immutable. onCommit receives a transaction containing before and after snapshots. Persist it using an optimistic revision check on your server, then update the controlled tasks and resolve. Reject on failure; the draft remains available for retry. applyGanttChangeSet checks local snapshots but does not replace server authorization or concurrency checks. Saving does not automatically move dependent tasks.
Undo and redo operate on the current draft. After saving, undo stages a reversal of the saved transaction; save again to persist it. Up to 50 saved transactions are retained in this mounted component. Server-side audit history remains an application concern. External updates during a draft pause saving and preserve the draft for review; discard it to load the latest version.
Unstaged forms are buffered per task, including when you switch tasks or close details. Apply each form to the draft before saving the schedule. Discard changes requires confirmation naming the affected tasks. Invalid data or calendar refreshes pause editing and retain the last valid view and all local input.
Native page reload and close prompts are enabled while forms, staged changes or saves are pending (browsers may require prior user interaction). Use onUnsavedChange to integrate your SPA router guard; this component cannot prevent arbitrary parent unmounts or client-side route transitions. The demo uses this callback to confirm project switches and leaving the view. Protecting against a browser crash requires application draft persistence.
Summary dates derive from descendants and cannot be edited directly. Parent IDs must reference summary tasks. Dependencies currently support FS between ordinary tasks or milestones; summary dependencies are rejected. lag uses calendar days unless lagUnit is working; working lags first align the exclusive finish to the next working day, then apply the signed offset. With a Friday last day and a normal Monday–Friday calendar, lag 0 allows Monday and lag 1 allows Tuesday; lag -1 allows Friday. Holidays and custom working weeks use the same rule. Calendar lags add directly to the exclusive finish without alignment. Dependency conflicts block saving, without silently rescheduling tasks.
Drag and keyboard moves preserve calendar duration. Choose calendar-day or working-day snapping; working-day snapping skips holidays and nonworking days in the direction of the move. Date forms accept exact dates. Nonworking days are shaded at readable day scales. Working calendars also apply to dependency lag calculations. Search includes names, assignees and statuses and keeps matching ancestors. Hidden dependency endpoints are counted, while the details panel preserves their textual relationships.
The existing Gantt remains available for period-based read-only roadmaps. Install this component with flab add gantt-schedule. A2UI GanttSchedule defaults to read only; editable with a bound tasks path saves to the local data model only. Use an application action for remote persistence.
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
tasks | readonly GanttTask[] | — | Controlled immutable task data. IDs are stable and unique; progress is optional (0–100). |
dependencies | readonly GanttDependency[] | — | FS edges with predecessorId, successorId and optional integer lag / lagUnit. |
onCommit | (changeSet) => void | Promise<void> | — | Omit for read only. Update controlled tasks before resolving; reject to retain edits. |
calendar | GanttWorkCalendar | — | workingDays uses weekday numbers 0–6 (default Monday–Friday); holidays uses YYYY-MM-DD. |
today | string | — | Explicit date-only value for the today line and navigation. |
locale / weekStartsOn | string / 0–6 | 'en' / 1 | Date formatting and week alignment. |
initialView / height | 'day' | 'week' | 'month' / number | 'week' / 440 | Time scale and timeline viewport height in pixels. |
onTaskSelect | (task) => void | — | Observe selection and open application-specific details. |
onUnsavedChange / protectUnsavedChanges | (boolean) => void / boolean | undefined / true | Observe pending forms, staged edits and saves for SPA navigation guards. Disable the native reload/close prompt only when your host supplies an alternative. |
readOnlyReason / getReadOnlyReason | string / (task) => string | undefined | — | Visible explanations for schedule or per-task restrictions. A task may also set lockedReason. |
loading / error / stale | boolean / string / string | — | Retain populated content during refresh. Loading, error and stale data pause editing. |
onRetry / onCreateTask | () => void | — | Recovery and empty-state actions owned by the application. |