GanttProps

Every prop ReactGanttChart accepts, with its type and default

GanttProps is the full prop surface of ReactGanttChart.

import { ReactGanttChart, type GanttProps } from '@jaeungkim/gantt-chart';

Every prop is optional. Every type in the tables below is exported from the package root apart from Dayjs, ReactNode and React.MouseEvent. The Default column carries the value the component falls back to. none means there is no fallback and the feature the prop drives stays off.

Data

PropTypeDefaultDescription
tasksTask[][]The task array, compared by contents. A new array with equal contents is ignored. See Task data.
onTasksChange(updatedTasks: Task[]) => voidnoneFires with the whole array after any committed edit. See Editing tasks.

Layout and size

PropTypeDefaultDescription
heightnumber | string600Chart height, a number in px or any CSS length. See Quick start.
widthnumber | string"100%"Chart width, a number in px or any CSS length. See Quick start.
classNamestringnoneAppended to the container's gantt-container class. See Theming.

Task list

PropTypeDefaultDescription
showTaskListbooleanfalseShows the left pane, which lists task names. See Task list and hierarchy.
showRowNumbersbooleanfalseShows each row's sequence in a narrow column before the name. See Task list and hierarchy.

Hierarchy

PropTypeDefaultDescription
hierarchybooleanfalseDerives depth and summary rows from parentId. See Task list and hierarchy.
collapsedIdsstring[]noneControlled set of collapsed ids. Omitted, the chart manages its own. See Task list and hierarchy.
defaultCollapsedIdsstring[][]Uncontrolled initial value, read once on mount. See Task list and hierarchy.
onCollapsedChange(collapsedIds: string[]) => voidnoneFires on every collapse toggle, controlled or not. See Task list and hierarchy.

Timeline and range

PropTypeDefaultDescription
defaultScaleGanttScaleKey"month"Scale the chart is built at, read once. See The timeline.
onScaleChange(scale: GanttScaleKey) => voidnoneFires after every committed scale change, from any source. See The timeline.
visibleStartstringnonePins the timeline's start to this ISO date. Omitted, the range fits the tasks. See The timeline.
visibleEndstringnonePins the timeline's end to this ISO date. Omitted, the range fits the tasks. See The timeline.
showNonWorkingDaysbooleantrueShades non-working days and shows holiday names. See The timeline.
workingWeekdaysnumber[][1, 2, 3, 4, 5]UTC day numbers that are worked, 0 is Sunday. The default is Monday to Friday. Read by identity. See The timeline.
holidays(string | Holiday)[]noneDays off on top of workingWeekdays, given as a YYYY-MM-DD string or a Holiday object. Omitted, the weekly rule is the only source. Read by identity. See The timeline.
onRangeChange(range: GanttDateRange) => voidnoneFires whenever the rendered range changes. See The timeline.

Zoom and scrolling

PropTypeDefaultDescription
zoomOnWheelbooleanfalseCtrl/Cmd + wheel steps through the scales in order. See The timeline.
infiniteScrollbooleanfalseGrows the rendered range when either end is approached. See The timeline.
initialScrollTo"today" | stringnoneScrolls once, after the timeline first renders. See Imperative API.
autoScrollOnDragbooleantrueA bar drag at a viewport edge scrolls the timeline. See Editing tasks.

Editing permissions

PropTypeDefaultDescription
readOnlybooleanfalseBlocks every gesture on every task. See Editing tasks.
allowMoveboolean!readOnlyAllows moving bars, overriding readOnly. See Editing tasks.
allowResizeboolean!readOnlyAllows resizing bars, overriding readOnly. See Editing tasks.
allowProgressChangeboolean!readOnlyAllows dragging the progress handle, overriding readOnly. See Editing tasks.
allowTaskCreateboolean!readOnlyAllows drafting a new task from the Add task button, addTask() or a drawn range. See Creating tasks.
allowReorderbooleanfalseAllows dragging a task-list row to a new position or a new parent. See Reordering rows.
minDatestringnoneEarliest ISO date any bar may be dragged to. See Editing tasks.
maxDatestringnoneLatest ISO date any bar may be dragged to. See Editing tasks.

Dependencies

PropTypeDefaultDescription
allowLinkCreateboolean!readOnlyAllows drawing dependencies between bars. See Dependencies.
allowLinkDeleteboolean!readOnlyAllows selecting and deleting dependency arrows. See Dependencies.
onDependencyCreate(change: GanttDependencyChange) => boolean | voidnoneRuns before a drawn link is applied. Return false to reject it. See Dependencies.
onDependencyDelete(change: GanttDependencyChange) => boolean | voidnoneRuns before an arrow is removed. Return false to keep it. See Dependencies.

Working calendar

PropTypeDefaultDescription
workingCalendarbooleanfalseSnaps a drag result forward off non-working days. See Working calendar.

Rendering

PropTypeDefaultDescription
showTooltipbooleantrueShows the hover card and the progress drag % readout. The dates written in the tick row during a drag are not affected. See Styling.

Events

PropTypeDefaultDescription
onTaskClick(task: TaskTransformed, event: React.MouseEvent) => voidnoneFires on a bar or row click, not after a drag. See Events.
onTaskDoubleClick(task: TaskTransformed, event: React.MouseEvent) => voidnoneFires on a double click. See Events.
onTaskSelect(task: TaskTransformed | null) => voidnoneFires when the selection changes, null on an empty-timeline click. See Events.
selectablebooleannoneTurns click selection and its highlight on. Omitted, selection follows onTaskSelect and the detail panel. See Events.
onTaskCreate(draft: GanttTaskDraft) => voidnoneFires with a draft range from the Add task button, addTask() or a drawn range. See Creating tasks.
onTaskMove(change: GanttTaskMoveChange) => boolean | voidnoneRuns before a row move is applied. Return false to reject it. See Reordering rows.

Detail panel

PropTypeDefaultDescription
renderDetailGanttDetailRenderernoneReplaces the docked panel's body and turns the panel on. Omitted, the built-in body is used. See Detail panel and Detail renderer.
showDetailbooleanrenderDetail !== undefinedShows the panel docked to the right of the timeline. See Detail panel.
detailTaskIdstring | nullnoneControlled open task, null for closed. Omitted, the chart keeps its own. See Detail panel.
onDetailChange(task: TaskTransformed | null) => voidnoneFires on every open and close, controlled or not. See Detail panel.

Locale and theme

PropTypeDefaultDescription
localestringnoneBCP 47 tag for every date label. Omitted, the built-in English labels are used. See Locale and date formats.
formatsGanttFormatOverridesnonePer-scale tick, header and tooltip label overrides. Omitted, the locale's labels are used. See Locale and date formats.
firstDayOfWeeknumbernoneGroups the week scale's top header, 0 is Sunday and 6 is Saturday. Omitted, week grouping is off. See Locale and date formats.
themeGanttThemenone'light', 'dark' or 'system'. Omitted, the host page's color-scheme decides. See Theming.

Derived defaults

  • selectable has no fixed default. Omitted, selection is on when onTaskSelect is given, and whenever the detail panel is on. Pass true for the highlight without a callback, false to turn it off entirely.
  • showDetail works the same way. Omitted, the detail panel exists when renderDetail is given. Turning the panel on also turns row selection on, unless selectable is given. See Detail panel.
  • allowMove, allowResize, allowProgressChange, allowTaskCreate, allowLinkCreate and allowLinkDelete default to !readOnly, not to true. A task's own flag of the same name wins over the chart-level one, and a task's own readOnly is between them. See GanttInteractionConfig.
  • allowTaskCreate creates nothing on its own, because onTaskCreate must also be given. Without it the button and the gesture are absent, and addTask() does nothing.
  • allowReorder defaults to false, not to !readOnly, so a chart that never sets it shows no row grips, and the reorder keys do nothing. A task's own allowReorder wins, and a task's readOnly: true blocks it. The chart's readOnly is not consulted. See GanttInteractionConfig.
  • defaultScale is an initial value, not a controlled one. It is read once, when the chart is constructed, so the first paint is already at that scale. Later changes to the prop are ignored, onScaleChange does not fire for them, and nothing is persisted, so a remount starts from the initial value again.
  • collapsedIds and defaultCollapsedIds are the controlled and uncontrolled halves of one value. Passing collapsedIds makes the chart show that list and stop tracking its own. onCollapsedChange fires in both modes.
  • theme has no default. Omitted, it follows the host page's color-scheme; 'system' reads the OS setting instead; 'light' and 'dark' hold everywhere, server rendering included. The resolution table is in Theming.
  • visibleStart and visibleEnd are independent. Pinning one end also stops infiniteScroll from extending the range on that side, and the other side still extends.
  • workingCalendar builds its calendar from workingWeekdays and holidays, the same two props that drive showNonWorkingDays shading.
  • workingWeekdays and holidays are compared by identity, not by contents. A fresh array on every render rebuilds the calendar on every render.

Notes

  • The task list has no column API. It shows task.name at a starting pane width of 220px, and everything else about a task belongs in the detail panel. See Task list and hierarchy.
  • GanttTaskMoveChange is what onTaskMove receives. It is exported from the package root and its fields are described in Tree helpers, next to the moveTask function that builds it.
  • GanttDependencyChange, GanttTaskDraft and GanttDateRange are exported from the package root. Their fields are described in Dependencies, Creating tasks and The timeline, next to the callback that receives each.
  • Dayjs is a dayjs type, and ReactNode and React.MouseEvent are react types. None of the three is re-exported from this package.
  • The chart does not render a toolbar or a scale picker. A host that wants one renders it, drives it with setScale on the ref and updates it from onScaleChange. See The timeline.
  • ReactGanttChart also takes a ref of type GanttHandle for scrolling, zooming, switching scale and opening or closing the detail panel. It is not part of GanttProps. See GanttHandle.