API Reference

<GanttChart /> Props

PropTypeDefaultDescription
tasksGanttTask[]RequiredThe array of task objects to render.
columnsGanttColumn[]Standard Name/DatesConfiguration for the left-hand data grid.
resourcesGanttResource[][]List of resources available for assignment. Required for resource leveling and the Resource Panel.
autoLevelResourcesbooleanfalseWhen true, runs resource leveling after each scheduling cascade.
onTasksChange(tasks) => voidCallback fired whenever tasks are mutated.
autoSchedulebooleanfalseWhen true, runs cascadeSchedule on every task change.
viewModeViewMode'day'Zoom level — controls the time scale header and pixel density.
themeGanttThemeBuilt-in Light ThemeCSS custom property token map to theme the component.
renderTask(task) => ReactNodeCustom renderer replacing the default task bar.
headlessbooleanfalseIf true, suppresses the injection of theme CSS custom properties.
showCriticalPathbooleanfalseIf true, highlights tasks with float <= 0.
showResourcePanelbooleanfalseIf true, renders the resource allocation histogram panel below the Gantt chart.
pluginsGanttPlugin[][]Plugin instances to install into the Gantt.
i18nPartial<I18nOptions>defaultI18nPartial i18n overrides for locale-specific strings.
calendarWorkingCalendarAllDayCalendarWorking calendar for scheduling and drag snapping.

GanttTask Structure

FieldTypeDescription
idstringUnique identifier for the task. Must be stable across renders.
namestringDisplay name of the task.
startDateThe scheduled start date/time.
endDateThe scheduled end date/time.
progressnumberCompletion percentage (0-100).
type'task' | 'group' | 'milestone'Task rendering variant. Default is 'task'.
parentIdstringID of the parent group task.
dependenciesTaskDependency[]Includes id, type (FS, SS, FF, SF), and optional lag (working days, negative for lead).
baselineStartDateOriginal planned start date. Display-only (gray shadow bar).
baselineEndDateOriginal planned end date. Display-only.
assignmentsTaskAssignment[]Resource assignments. Used by the Resource Panel to calculate utilization.
floatnumberRead-only. Total float in milliseconds. <= 0 means critical path.
constraintTaskConstraintScheduling constraint (ASAP, ALAP, SNET, MSO).
constraintDateDateRequired date for SNET and MSO constraints.

Context API (useGanttContext)

If you are building custom UI overlays, external toolbars, or advanced plugins, you can consume the internal Gantt state via the useGanttContext hook.

import { useGanttContext } from 'ganttcraft';

function CustomGanttToolbar() {
  const { tasks, historyManager, undo, showCriticalPath } = useGanttContext();
  
  return (
    <div>
      <button onClick={undo} disabled={!historyManager.canUndo()}>Undo</button>
      <span>Total Tasks: {tasks.length}</span>
    </div>
  );
}

Available Context Properties:

  • tasks (GanttTask[]): The current scheduled state of all tasks.
  • columns / resources (array): The columns and resources passed into the chart.
  • updateTask (function): Updates a task, cascades schedule if autoSchedule is on, and registers an undo command.
  • addDependency (function): Programmatically draws an FS dependency between two tasks.
  • deleteTask (function): Removes a task and cleans up any dangling dependencies pointing to it.
  • viewMode (ViewMode): The current timescale resolution.
  • virtualWindow (VirtualWindow): Describes which rows are currently rendered in the virtualized scroll view.
  • historyManager (HistoryManager): The internal manager handling the undo/redo stack.
  • undo / redo (function): Triggers undo/redo actions directly.
  • conflicts (ConflictMap): Map of constraint conflicts or scheduling errors detected in the current run.