Vanilla Gantt

A Gantt web component (<vn-gantt>): a task tree shown as bars on a timeline. The left pane is an embedded <vn-grid> in tree mode, the task list; the right pane is the timeline, with one bar per row the grid renders. Both axes are virtualized, so 1,000,000 tasks scroll like 1,000,000 grid rows.

It requires the grid on the page, loaded first: the task list is a real <vn-grid> (columns, resizing, sorting, filtering, search, keyboard, tree rows), and the Gantt reads the grid's shared utilities at runtime.

The design docs are in docs/vanilla-gantt/; the project-tasks-js sample shows a generated plan of 1,000 to 1,000,000 tasks.

Features

Installation

Development (each component auto-loads its own files):

<script src="vanilla-grid/vanilla-grid.js"></script>
<script src="vanilla-gantt/vanilla-gantt.js"></script>

Production (npm run build writes dist/vanilla-components/latest/):

<script src="vanilla-grid/vanilla-grid.bundle.js"></script>
<script src="vanilla-gantt/vanilla-gantt.bundle.js"></script>

The Gantt's stylesheets (vanilla-gantt.css, themes/vn-gantt-*.css) are injected by the element, relative to its script. vanilla-gantt.d.ts ships next to the bundle and imports the grid's types from ../vanilla-grid/.

Usage

New to the Gantt? Getting started builds one step by step, with a live example at each step.

<vn-gantt id="plan" theme="default" zoom="week" style="height: 600px"></vn-gantt>

<script type="module">
    const gantt = document.getElementById('plan');
    await window.VanillaGanttReady;
    await gantt.ready();

    gantt.setDataManager(new VanillaGanttStaticDataManager({
        tasks: [
            { id: 'p1', parentId: null, name: 'Phase 1', start: '', end: '' },
            { id: 't1', parentId: 'p1', name: 'Design', start: '2026-10-12', end: '2026-10-16' },
            { id: 't2', parentId: 'p1', name: 'Build',  start: '2026-10-16', end: '2026-10-30' },
            { id: 'm1', parentId: 'p1', name: 'Release', start: '2026-10-30', end: '2026-10-30' },
        ],
        dependencies: [
            { from: 't1', to: 't2' },                 // finish-to-start (the default)
            { from: 't2', to: 'm1', type: 'FF' },
        ],
    }));
    gantt.initializeGantt({ taskListWidth: 480 });
    await gantt.loadTasksAsync();
</script>

A task's start and end are calendar days: 'YYYY-MM-DD', epoch ms or a Date (both floored to their UTC day). end is exclusive, the day after the last day; end == start is a milestone. A summary's own dates are ignored.

Columns

The task list shows the five built-in columns unless the host lists its own, in columns or as <vn-grid-column> children of <vn-gantt> with the grid's attributes. A column bound to a built-in by ganttValue (in markup, gantt-value) keeps the Gantt's definition and changes only what it sets; any other column reads a field the host puts on its tasks:

<vn-gantt id="plan">
  <vn-grid-column gantt-value="name" width="220"></vn-grid-column>
  <vn-grid-column gantt-value="start"></vn-grid-column>
  <vn-grid-column gantt-value="end"></vn-grid-column>
  <vn-grid-column kind="data" column-key="owner" header="Owner" type="string" width="100"></vn-grid-column>
</vn-gantt>
gantt.initializeGantt({
    columns: [
        { ganttValue: 'name', label: 'Aufgabe', width: 220 },
        { ganttValue: 'duration' },
        { kind: 'data', key: 'owner', label: 'Owner', type: 'string', width: 100 },
    ],
    searchFields: ['name', 'owner'],
});

The markup is read in place at each initializeGantt(), so a framework keeps owning those nodes. A column keyed like a built-in with no ganttValue is a plain grid column over the task's own field.

To add expand-all and collapse-all, link a toolbar to the task grid with <vn-gantt-toolbar>, a <vn-grid-toolbar> that names the Gantt by its id and links its task grid once the Gantt is initialized, and use its standard expandAllRows / collapseAllRows commands:

<vn-gantt-toolbar gantt="plan"> … </vn-gantt-toolbar>

Attributes

Attribute Default Description
theme default default, default-dark, or a registered theme. Applied to the timeline and the embedded grid
theme-css-path A stylesheet that replaces the timeline's theme (the grid keeps theme)
zoom week day, week, month, quarter or year. Reflects the level in effect
read-only Present: no bar can be moved
tree-column The key of the column holding the tree toggles, read at initializeGantt(); the treeColumn option wins

Options (initializeGantt(options))

Option Default Description
zoom the zoom attribute, else 'week' Clamped to the finest level whose timeline fits the engine's width cap
columns the <vn-grid-column> children, else name (tree column), start, end, duration, id The task list's columns, in order. A column with a ganttValue ('name', 'start', 'end', 'duration' or 'id') is that built-in column with the column's other properties over it; any other column is a grid column over the task's fields. The Duration filter compares days. Wins over the markup columns
treeColumn the tree-column attribute, else the column bound to 'name', else a column keyed name, else the first visible data column The key of the column holding the tree toggles
searchFields ['name', 'id'] The task fields the task list's search covers (dotted paths allowed; [] searches every scalar field)
taskListWidth the width in effect (360 on a first call) The task grid's width, px; at least minTaskListWidth
minTaskListWidth 120 px; the task list is never narrower, by the splitter, setTaskListWidth() or a narrower Gantt
minTimelineWidth 160 px; the splitter never makes the timeline narrower, and a narrower Gantt squeezes the task list first
splitterStep, splitterLargeStep 10, 50 px the focused splitter moves per Left / Right and per Shift+Left / Shift+Right
readOnly Sets the read-only attribute
highlightSearchMatches false A search marks its match in the columns it searches (by default the task names and ids)
locale navigator.language Also passed to the grid
messages Overrides for durationDays, taskLabel, milestoneLabel (a task that starts and ends on the same day), loading, error, splitterLabel, timelineLabel (the timeline's accessible name, 'Timeline')
logger console false or null silences the Gantt (and the grid)

Properties

Property Description
theme, themeCssPath, zoom, readOnly Reflect the attributes

Methods

Method Description
ready() Resolves when the grid, the Gantt and their stylesheets (the task grid's included) have loaded; rejects with code 'grid-missing' without the grid
initializeGantt(options) Builds both panes; returns the VanillaGantt instance
getTaskGrid() The embedded <vn-grid>; undefined before initializeGantt()
getTaskListWidth(), setTaskListWidth(px) The task list's width as last set (by taskListWidth, this method, the splitter or fitTaskListWidth()). Setting it clamps to minTaskListWidth and fires nothing; before initializeGantt() it sets the width the panes are built with
fitTaskListWidth() Sets the task list's width to its visible columns, so the last one ends at the splitter; the columns keep their widths. At least minTaskListWidth, at most the width that leaves the timeline minTimelineWidth (wider columns scroll sideways, and a Gantt widened later grows the timeline). Fires vn-gantt-task-list-resized with source: 'fit' when the width changed. false before initializeGantt(), else true
setDataManager(dm), getDataManager() The data source
loadTasksAsync() Fetch and show the tasks; the last call wins. Both panes show a loading state until the rows are on screen
reloadDataManager() reset(), then loadTasksAsync()
setAutoReloadOnConfigChange(enabled) Reload whenever the manager's setters fire onConfigChanged
setTheme(theme), setZoom(zoom), zoomIn(), zoomOut() Theme and zoom
scrollToTask(id, options?) Expand the task's ancestors and scroll its row and bar into view; { focus: true } also selects the task and moves keyboard focus to the timeline. false when unknown, and before initializeGantt()
scrollToDate(date) Centre the timeline on a date
getTask(id), getTaskCount(), getDateRange() Read the loaded plan
destroy() Tear the Gantt down

Static: VanillaGanttElement.SUPPORTED_THEMES, getSupportedThemes(), registerTheme(name, cssPath); VanillaGantt.registerLocale(name, messages), getLocaleMessages(name), defaultLocale.

Data managers

Class Description
VanillaGanttDataManager Base class: fetchTasks({ signal }), fetchDependencies({ signal }), updateTasks(changes) (read-only: rejects), reset(), destroy(), onConfigChanged
VanillaGanttStaticDataManager In memory: setTasks(), setDependencies(), getTasks(), getDependencies(), and an updateTasks() that writes start / end onto the stored tasks, or rejects changing nothing when an id is unknown

Events

Named in window.VanillaGanttEvents; all bubble and are composed.

Event Detail
vn-gantt-loading {}
vn-gantt-loaded { taskCount, dependencyCount }, once both panes show the tasks; dependencyCount counts the links that resolved
vn-gantt-error { error }
vn-gantt-task-move { task, changes, source }; cancelable, before a move is applied (preventDefault() puts every bar back)
vn-gantt-task-moved { task, tasks, previous, source }; after updateTasks() resolved
vn-gantt-task-move-failed { task, code, error? }; code is 'dependency-cycle' or 'manager-rejected'
vn-gantt-zoom-changed { zoom, previousZoom }
vn-gantt-task-list-resized { width, source }; the task list's width changed with the splitter or a fit: once per drag ('pointer'), once per key press ('keyboard'), once per fitTaskListWidth() call or splitter double-click ('fit') that changed it (not for setTaskListWidth()). The Gantt doesn't persist the width: save width and pass it back as taskListWidth
vn-gantt-task-dblclick { task, pane }; a double-click on a task's grid row (pane: 'grid') or its bar (pane: 'timeline'), once the task is selected. Fired before the grid's own vn-grid-row-dblclick reaches <vn-gantt>

Theming

theme="default-dark" loads themes/vn-gantt-default-dark.css for the timeline and sets the same theme on the grid. Every colour, the bar height and radius, the links' colours, width and dash, the move preview, the selected bar's ring and the timeline's focus outline, the scrollbar and the splitter's line (--vn-gantt-splitter-color, --vn-gantt-splitter-active-color) come from --vn-gantt-* custom properties set by the theme on .vn-gantt (the full list is in 06-themes). A custom theme is a stylesheet registered with VanillaGanttElement.registerTheme(name, cssPath), next to a grid theme of the same name (VanillaGridElement.registerTheme()). Themes are page-global, like the grid's: two Gantts with different themes on one page both take the last-loaded theme.

File structure

vanilla-gantt/
  vanilla-gantt.js               core class, locale registry, dev auto-loader
  vanilla-gantt-events.js        VanillaGanttEvents
  vanilla-gantt-element.js       <vn-gantt>
  features/
    timeline-scale.feature.js    zoom levels, day to px, ticks, width cap
    tasks.feature.js             task model: dates, tree, roll-up
    rendering.feature.js         lane pool, bars, tick pool
    scroll-sync.feature.js       following the grid, wheel and touch input
    scrollbar.feature.js         the horizontal scrollbar
    splitter.feature.js          the splitter: drag, keys, the fit, its event
    dependencies.feature.js      link index, routing, the SVG link layer
    scheduling.feature.js        push and roll-up engine
    task-move.feature.js         drag, touch hold, keyboard selection, commits
  data-managers/
    gantt-data-manager.js        VanillaGanttDataManager
    static-gantt-data-manager.js VanillaGanttStaticDataManager
  vanilla-gantt.css              structure
  themes/                        vn-gantt-default.css, vn-gantt-default-dark.css
  vanilla-gantt.d.ts             hand-authored TypeScript declarations

Changelog

Version 1.2.0

Version 1.1.1

Version 1.1.0

Version 1.0.0