Define your data
A Gantt chart requires three props:
tasks, links, and scales.Tasks are the items displayed on the chart. Each task needs an id, start, end (or duration), and text. Use parent: 0 for top-level tasks and type: "summary" for parent tasks with subtasks.Links define dependencies between tasks. Each link has a source and target (task IDs) and a type ("e2s" for end-to-start, "s2s" for start-to-start, "s2e" for start-to-end).Scales configure the header rows of the timeline. Each scale entry specifies a time unit, a step, and a format string.JavaScript’s
Date constructor uses zero-based months: new Date(2026, 3, 2) is April 2, 2026.Render the Gantt component
Import The
Gantt and a theme wrapper from @svar-ui/svelte-gantt, then wrap the chart in the theme component and pass your data as props.<Willow> wrapper injects the default light theme styles. You can swap it for <WillowDark> or <Material> without changing any other code.Choose a theme
Three themes are bundled with the package. Wrap your
<Gantt> in whichever component matches your app’s design.- Willow (light)
- WillowDark
- Material
Access the API with the init prop
The You can also bind the component instance with
init prop gives you access to the IApi object, which exposes methods for programmatic control — adding tasks, listening to events, executing actions, and integrating a data provider.Pass a function to the init prop. It is called once when the component mounts, with the API object as its argument.bind:this to call API methods reactively:Complete example
The following is a self-contained Svelte component that renders a Gantt chart with tasks across multiple phases, dependency links between them, and a month/day time scale.Next steps
Tasks and links
Full reference for task fields, link types, milestones, and summary tasks.
Scales and zoom
Configure multi-row time scales, zoom levels, and custom scale units.
Columns
Customize the grid columns shown alongside the timeline.
API reference
Full reference for all component props, events, and the IApi object.