Skip to main content
The Gantt component renders the full Gantt chart with a left-side grid and a right-side timeline. It accepts data, configuration, and event handler props.

Import

Basic usage

Accessing the API with init

Use the init prop to receive the IApi object when the component mounts. This is the recommended way to interact with the Gantt programmatically.
Alternatively, bind this to get the API object as a Svelte component reference:

Props

Data

ITask[]
default:"[]"
Array of task objects to display. Each task can include id, text, start, end, duration, parent, type, progress, and other fields.
Array of dependency links between tasks.
ITaskType[]
Custom task type definitions. Defaults to built-in types (task, summary, milestone).

Timeline

IScaleConfig[]
Array of scale rows displayed in the timeline header. Defaults to month + day scales.
Date
default:"null"
Start date of the visible timeline range. When autoScale is true (the default), this is computed from the task data.
Date
default:"null"
End date of the visible timeline range. When autoScale is true, this is computed from the task data.
TLengthUnit
default:"day"
The base unit used to measure durations and position tasks on the timeline. Accepted values: "minute", "hour", "day", "week", "month", "quarter", "year".
TDurationUnit
default:"day"
Unit used for task duration values. Accepted values: "day", "hour".
number
default:"100"
Width in pixels of each timeline cell.
number
default:"38"
Height in pixels of each task row.
number
default:"36"
Height in pixels of each scale header row.
boolean
default:"true"
When true, the visible date range is automatically computed from the task data. Set to false to use explicit start and end props.
boolean | IZoomConfig
default:"false"
Enables pinch-to-zoom and scroll-wheel zoom on the timeline.Pass true to use defaults, or an IZoomConfig object for fine-grained control:
IMarker[]
default:"[]"
Vertical marker lines drawn on the timeline.

Grid

false | IColumnConfig[]
Column definitions for the left-side grid. Pass false to hide the grid entirely. Defaults to built-in columns (text, start, duration).

Selection

TID[]
default:"[]"
IDs of the currently selected tasks.
TID | { id: TID; segmentIndex: number }
default:"null"
ID of the currently active (focused) task. Accepts either a plain ID or an object specifying a segment index for split tasks.

Appearance

boolean
default:"false"
When true, disables all user interactions (drag, resize, edit). The chart becomes view-only.
'column' | 'full'
default:"full"
Controls which cell borders are drawn in the timeline grid. "full" draws all borders; "column" draws only vertical separators.
(date: Date, unit: 'day' | 'hour') => string
default:"null"
A function that returns a CSS class name for a given date cell. Use it to highlight weekends, holidays, or other date ranges.
Component<{ data: ITask; api: IApi; onaction: (ev: { action: string; data: Record<string, any> }) => void }>
default:"null"
A custom Svelte component used to render task bars in the timeline. Receives data (the task object), api (the Gantt API), and an onaction dispatcher.

Scheduling

IScheduleConfig
default:"{ type: 'forward' }"
Auto-scheduling configuration.
Calendar
default:"null"
A Calendar instance that defines working days and hours. When provided, durations are calculated in working time and non-working days are highlighted automatically.
ISummaryConfig
default:"null"
Controls automatic behaviour for summary tasks.

Features

boolean
default:"false"
Enables undo/redo support. Use api.exec("undo") and api.exec("redo") to trigger.
boolean
default:"false"
Shows baseline bars for tasks that have base_start and base_end set.
false | { type: 'all' | 'closest' }
default:"false"
Renders child task bars inside collapsed summary task bars. "closest" shows only direct children; "all" shows all descendants.
ICriticalPathConfig
default:"null"
Highlights the critical path of the project.
boolean
default:"false"
Enables split tasks (tasks composed of multiple segments).
boolean
default:"false"
Shows a row for tasks that have no start date (unscheduled: true).
boolean
default:"false"
Shows slack (float) bars next to tasks when a critical path configuration is active.

Init

(api: IApi) => void
default:"null"
Callback invoked once after the component mounts. Receives the IApi object. Use this to subscribe to events or call API methods on initialisation.

Event props

Each Gantt action can be intercepted via an on<ActionName> prop. The prop name is derived from the action name by removing hyphens and prepending on.
Event props receive the same payload as the corresponding api.on() callback. Returning false from an event prop does not cancel the action — use api.intercept() for that.
The following event props are available: