Getting Started with vanilla-gantt

<vn-gantt> shows a plan as a task list beside a timeline of bars. The task list is a <vn-grid> in tree mode, so summaries open and close, and the columns sort and filter as in any grid. Each step shows the running example and its whole source, a complete page you can copy.

What you need. The grid's script, vanilla-grid.bundle.js, then vanilla-gantt.bundle.js, from the build's dist/vanilla-components/latest/ folder, in that order. The Gantt adds its own stylesheets to the page.

1. Your first plan

Each task has an id, a parentId (null at the top level), a name, and start and end days ('YYYY-MM-DD', epoch milliseconds or a Date). end is the day after the last day. A task with children is a summary: its bar spans its children, and its own dates are ignored. A task that ends on the day it starts is a milestone. Each dependency draws an arrow from one task to another; finish-to-start is the default.

VanillaGanttStaticDataManager holds the plan in memory. Once window.VanillaGanttReady and the element's ready() resolve, attach it with setDataManager(), build both panes with initializeGantt() (taskListWidth sets the task list's width; the user can drag the line between the panes), and load with loadTasksAsync().

The user can drag a bar to move a task; the tasks that depend on it move with it.

Example: your first planOpen in a new tab ↗
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Your first plan</title>
  <style>
    html, body { height: 100%; margin: 0; font-family: system-ui, sans-serif; }
    vn-gantt { display: block; height: 100%; }
  </style>
</head>
<body>
  <vn-gantt id="plan"></vn-gantt>

  <!-- The grid's script first: the Gantt's task list is a <vn-grid>. -->
  <script src="path/to/vanilla-grid/vanilla-grid.bundle.js"></script>
  <script src="path/to/vanilla-gantt/vanilla-gantt.bundle.js"></script>
  <script type="module">
    await window.VanillaGanttReady;
    const gantt = document.getElementById('plan');
    await gantt.ready();

    // start and end are days; end is the day after the last day.
    // A summary (Phase 1, Phase 2) takes its dates from its tasks.
    // A task that ends on the day it starts is a milestone.
    const tasks = [
      { id: 'p1', parentId: null, name: 'Phase 1', start: '', end: '' },
      { id: 't1', parentId: 'p1', name: 'Design', start: '2026-11-02', end: '2026-11-05' },
      { id: 't2', parentId: 'p1', name: 'Build', start: '2026-11-05', end: '2026-11-12' },
      { id: 'p2', parentId: null, name: 'Phase 2', start: '', end: '' },
      { id: 't3', parentId: 'p2', name: 'Test', start: '2026-11-12', end: '2026-11-17' },
      { id: 'm1', parentId: 'p2', name: 'Release', start: '2026-11-17', end: '2026-11-17' },
    ];
    // Each dependency draws an arrow; finish-to-start is the default.
    const dependencies = [
      { from: 't1', to: 't2' },
      { from: 't2', to: 't3' },
      { from: 't3', to: 'm1' },
    ];

    gantt.setDataManager(new VanillaGanttStaticDataManager({ tasks, dependencies }));
    gantt.initializeGantt({ taskListWidth: 200 });
    await gantt.loadTasksAsync();
  </script>
</body>
</html>

2. Zoom levels

The zoom attribute sets the timeline's scale: day, week (the default), month, quarter or year. setZoom() changes it at runtime.

Example: zoom levelsOpen in a new tab ↗
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Zoom levels</title>
  <style>
    html, body { height: 100%; margin: 0; font-family: system-ui, sans-serif; }
    body { display: flex; flex-direction: column; }
    label { padding: 8px; }
    vn-gantt { display: block; flex: 1; min-height: 0; }
  </style>
</head>
<body>
  <label>Zoom
    <select id="zoom">
      <option value="day">Days</option>
      <option value="week" selected>Weeks</option>
      <option value="month">Months</option>
      <option value="quarter">Quarters</option>
      <option value="year">Years</option>
    </select>
  </label>

  <!-- zoom: the starting scale of the timeline. -->
  <vn-gantt id="plan" zoom="week"></vn-gantt>

  <script src="path/to/vanilla-grid/vanilla-grid.bundle.js"></script>
  <script src="path/to/vanilla-gantt/vanilla-gantt.bundle.js"></script>
  <script type="module">
    await window.VanillaGanttReady;
    const gantt = document.getElementById('plan');
    await gantt.ready();

    const tasks = [
      { id: 'p1', parentId: null, name: 'Phase 1', start: '', end: '' },
      { id: 't1', parentId: 'p1', name: 'Design', start: '2026-11-02', end: '2026-11-05' },
      { id: 't2', parentId: 'p1', name: 'Build', start: '2026-11-05', end: '2026-11-12' },
      { id: 'p2', parentId: null, name: 'Phase 2', start: '', end: '' },
      { id: 't3', parentId: 'p2', name: 'Test', start: '2026-11-12', end: '2026-11-17' },
      { id: 'm1', parentId: 'p2', name: 'Release', start: '2026-11-17', end: '2026-11-17' },
    ];
    const dependencies = [
      { from: 't1', to: 't2' },
      { from: 't2', to: 't3' },
      { from: 't3', to: 'm1' },
    ];

    gantt.setDataManager(new VanillaGanttStaticDataManager({ tasks, dependencies }));
    gantt.initializeGantt({ taskListWidth: 200 });
    await gantt.loadTasksAsync();

    // setZoom() changes the scale at runtime.
    document.getElementById('zoom').addEventListener('change', (e) => {
      gantt.setZoom(e.target.value);
    });
  </script>
</body>
</html>

Next steps