Svelte Gantt

DHTMLX Svelte Gantt chart is a separate Gantt chart library for your Svelte application.

There are two different products, DHTMLX Gantt and DHTMLX Svelte Gantt. While they are very similar in UX, they are very different in API.

Supported functionality

Common with DHTMLX Gantt

  • adding/editing/deleting tasks and links
  • tasks, projects and milestones
  • configurable scales and grids
  • configurable tooltips
  • time markers

Unique features

  • svelte widgets can be used for tasks rendering, tooltips and form controls
  • all configuration properties are reactive
  • full svelte sources are provided



  • add the svelte-gantt library into your Svelte project by the following command:
npm install @dhtmlx/trial-svelte-gantt

This command will install the Trial version, for Commercial one, use "@dhx/svelte-gantt".

  • place the Gantt tag into the desired page:
import { Gantt, DefaultTheme } from "@dhtmlx/trial-svelte-gantt";
export default function GanttBasic() {
    return (
            <Gantt />

You can check the demo of our minimal project here. You will find the source code of the gantt in the node_modules/@dhtmlx/trial-svelte-gantt/src folder.


The svelte-gantt package contains two predefined themes - Default and Material.

You can apply the desired theme by wrapping Gantt into the DefaultTheme or MaterialTheme tags:

        <Gantt />
        <Gantt />

or you can just add the theme tag on the page and add a skin class into one of the parent tags of Gantt:

    <DefaultTheme />
    <MaterialTheme />
    <div class="wx-default">
        <Gantt />
    <div class="wx-material">
        <Gantt />


You can define scales/columns/tasks/links during Gantt initialization:

<Gantt {scales} {columns} {tasks} {links} />

where data may look like this:

const scales = [
    { unit: "month", step: 1, format: "MMMM yyy" },
    { unit: "day", step: 1, format: "d" },
const columns = [
    { name: "text", label: "Task name", width: "100%" },
    { name: "start", label: "Start time", align: "center" },
    { name: "duration", label: "Duration", width: "70px", align: "center" },
    { name: "add-task", label: "", width: "50px", align: "center" },
const tasks = [
        id: 1,
        open: true,
        start_date: "2020-11-06",
        duration: 8,
        text: "svelte Gantt Widget",
        progress: 60,
        type: "project",
        id: 2,
        parent: 1,
        start_date: "2020-11-06",
        duration: 4,
        text: "Lib-Gantt",
        progress: 80,
const links = [{ source: 2, target: 1, type: 0 }];

Integration with backend

Let's take a look at GanttBackend.svelte.

Code defines the action handler through the save event. This event will be triggered on any update and may be used to save changes to the persistent storage.

In the above example, RestDataProvider is used. You are not limited to this solution, though, and can extend the provided class or define a custom handler.

We provide you with 2 demo backends:

Again, you are not limited to this solution. The above RestDataProvider can work with any REST like service and you can implement a fully custom solution ( sockets, graphql, etc. ) through a custom save event.


The following elements can be customized via templates:

  • task text
  • sidebar form

–°heck the code example here.

  • tooltip content

–°heck the code example here.



// templates for different elements of gantt
let templates = {};
// array of markers
let markers = [];
// supported task types
let taskTypes = ["task", "project", "milestone"];
// tasks data
let tasks = [];
// links data
let links = [];
// time scales configuration
let scales = [
    { unit: "month", step: 1, format: "MMMM yyy" },
    { unit: "day", step: 1, format: "d" },
// grid configuration
let columns = [
    { name: "text", label: "Task name", width: "100%" },
    { name: "add-task", label: "", width: "50px", align: "center" },
// time scale start
let start = null;
// time scale end
let end = null;
// width of scale cell
let cellWidth = 100;
// height of chart bar
let cellHeight = 38;
// height of scale cell
let scaleHeight = 30;
// read-only mode flag
let readonly = false;
// show or hide grid
let grid = true;
// show or hide tooltips
let tooltip = null;
// show or hide borders in the chart area
let borders = "full";


// will be called on any action in the Gantt
let actions = null;
// will be called on any data modification in the Gantt
let save = null;


Data modifications ( both action and save events )

  • add-link
  • update-link
  • delete-link
  • add-task
  • update-task
  • delete-task

UI State ( action event )

  • data-request
  • hide-details
  • move-task
  • scroll-chart
  • select-task
  • show-details
  • task-toggle
  • update-task-time

Example of event usage

function handler({ action, obj, id }) {
    if (action === "select-task") console.log(`Task ${id} was selected`);
<Gantt on:action={handler} />;


Retrieve the store object:

let store;
<Gantt bind:store />;

and now you can use the store's API to get or modify data:

interface IStore {
    getTask(id: number): GanttItemData;
    updateTask(id: number, obj: any, noSave: boolean): void;
    updateLink(id: number, obj: any, noSave: boolean): void;
        id: number,
        action: string,
        obj: StringHash<any>,
        noSave?: boolean
    ): number;

The action method can be used to trigger any of the above actions:

store.action(taskId, "tasks-toggle");
store.action(linkId, "delete-link");
store.action(null, "add-link", { source: 1, target: 2, type: 0 });
Back to top