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
- Task tree from each task's
parentId, with expand and collapse, sorting within siblings, filters and search that keep every match's ancestors: the grid's tree rows. - Task-list columns like a grid's: the five built-ins (Task, Start, End,
Duration, Id) bound by
ganttValueand changed only where the host says, custom columns over fields on the tasks, the tree toggles on any column, and the search over any task fields; in JS or as<vn-grid-column>children in markup. - Summary tasks (tasks with children) always span their children, shown as brackets; their dates are rolled up and written back for the grid's cells.
- Milestones (
end == start) shown as diamonds. - Dependency links of four types (
FS,SS,FF,SF), drawn as orthogonal arrows for the links that cross the view only, even when both ends are off-screen. A link that its successor's dates break is shown as violated. A link into a collapsed summary is drawn, dashed, to the summary's bar; a link inside one is hidden, and so is a link whose end a filter or search leaves out. - Moving tasks: drag a bar with the mouse or pen, hold and drag it by
touch, or press
Shift+ArrowLeft/Shift+ArrowRightwith focus in the timeline to move the selected task. A bar moves by whole days on its own row; the successors a move breaks are pushed later, transitively, and summaries roll up, all previewed while dragging. A move into a dependency cycle is refused. Every move goes through a cancelable event and oneupdateTasks()call, and is reverted whole if the manager rejects it.read-onlyturns moving off. - Keyboard: three tab stops, whatever the number of tasks: the task
grid, the splitter and the timeline (the tree toggles are out of the tab
order, and no bar is ever focused). The arrows, pages,
HomeandEndact with the pointer over either pane or focus in either: with a task selected they move the selection (up, down, a page, to the first or last task), and with none they scroll both panes.Space(orShift+Space) selects the first fully visible task, or clears the selection so the keys scroll again. In the grid pane,ArrowRight/ArrowLeftexpand and collapse the selected task and move to its first child or its parent (swapped under RTL); with focus in the timeline they scroll it. The timeline shows a focus outline while it has keyboard focus, and a live region announces the task a key selects. - Selecting a task: the task grid has single selection, with no checkbox
column. A click on a row (anywhere along it, up to the splitter), a press
on a bar or the keys above select one task, and every selection change but a bar press scrolls the timeline
sideways to its bar. The selected task shows in both panes at once: its grid row's tint and
selection marker, its lane's tint, and a ring around its bar. A bar has the
ring exactly when its task is selected.
Hover reads as one row across both panes too: the mouse over a row tints
its lane, and over a lane or bar tints its row. The hover tint covers the
selected one, so the selection shows under the pointer through the grid's
selection marker, an accent bar on the row's inline-start edge, and the
bar's ring.
getTaskGrid()'s selection methods andvn-grid-selection-changedwork with task ids, and<vn-gantt-toolbar>'sscrollToSelectedTaskcommand brings the selected task back into view after scrolling away. - Double-clicking a task, on its grid row or on its bar (mouse, pen, or a
double tap), selects it and fires
vn-gantt-task-dblclickwith the task and the pane, to open its details, say. A press that became a drag never counts, and it works read-only too. - Five zoom levels,
day,week,month,quarterandyear, each with a two-tier header. Zooming keeps the date at the centre in place. - Virtualized both ways. The grid owns vertical scrolling and its row pool; the timeline draws one lane per pooled row, in natural and scaled mode, and only the header ticks near the view.
- Input over the timeline: a vertical wheel scrolls the grid exactly as a wheel over it does; a vertical touch drag scrolls the grid, with momentum on release; horizontal wheel and touch scroll the timeline.
- One frame, with a splitter. The task list and the timeline share one
frame; the line between them is a splitter that resizes both panes as it
is dragged (mouse, touch or pen) or moved with the keyboard, within a
minimum width for each.
fitTaskListWidth(), or a double-click on the splitter, moves it to the last task-list column's right edge.vn-gantt-task-list-resizedreports a change by the splitter or a fit. - The scrollbars at the edges: the timeline's own horizontal scrollbar, with the grid's look and mechanics, and the task grid's vertical scrollbar at the timeline's right edge.
- Bad data handled once: duplicate ids, unknown parents and parent cycles are resolved by the Gantt, and the grid is given the same tree, so both panes always agree.
- Two themes,
defaultanddefault-dark, with the look of the grid's two default themes, applied to both panes by onethemeattribute. Under forced colors (Windows High Contrast) the timeline paints itself in system colours, and the selected task's lane is outlined inHighlight. - Performance: at 1M tasks the timeline adds about 1 ms of lane pass and no
layout to the grid's scroll frame (
tests/playwright/gantt-scroll-performance.spec.js). - DataManager architecture:
VanillaGanttStaticDataManagerfor in-memory data, or a subclass ofVanillaGanttDataManagerfor any other source. - Localization through
VanillaGantt.registerLocale(), dates byIntlin UTC.
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
- Added (
vanilla-gantt) - task-list columns like a grid's: a column'sganttValue('name','start','end','duration'or'id';gantt-valuein markup) binds it to a built-in definition that the entry changes only where it sets a property, any other column reads a field on the tasks, and the columns can be<vn-grid-column>children of<vn-gantt>. NewVanillaGanttColumnDefandVanillaGanttBuiltInValuetypes;columnsnow takesVanillaGanttColumnDef[]. - Added (
vanilla-gantt) -treeColumnoption andtree-columnattribute (the key of the column holding the tree toggles), and thesearchFieldsoption (the task fields the task list's search covers, default['name', 'id']). - Added (
vanilla-gantt) -fitTaskListWidth()sets the task list's width so the last visible column ends at the splitter (at leastminTaskListWidth, at most the width that leaves the timelineminTimelineWidth); a double-click on the splitter does the same.vn-gantt-task-list-resizednow fires for it withsource: 'fit'(VanillaGanttTaskListResizedDetail.sourceis'pointer' | 'keyboard' | 'fit'). - Maintenance -
docs/vanilla-gantt/updated;project-tasks-jsadopts the columns (an Assigned to and a Progress column, with a pie renderer, over new task fields) and the fit.
Version 1.1.1
- Fixed (
vanilla-gantt) - each task row's space past its last column now comes from the grid's own row filler (vanilla-grid1.56.0), so its divider line uses the grid theme's--vn-grid-row-border-colorinstead of--vn-gantt-border-color, matching the row's cells under any registered theme pair; the Gantt's own filler rules are removed fromvanilla-gantt.css. - Maintenance -
docs/vanilla-gantt/updated.
Version 1.1.0
- Added (
vanilla-gantt) - double-clicking a task, on its grid row or on its bar (mouse, pen or double tap), selects it and fires the newvn-gantt-task-dblclickevent (VanillaGanttEvents.TASK_DBLCLICK) with{ task, pane }; a press that became a drag never counts. - Added (
vanilla-gantt) - anIdcolumn in the default task grid columns, and the task search now matches task ids as well as names. - Changed (
vanilla-gantt) - link positions are looked up with onegetTreeRowPositions()call, which speeds up loading plans with many dependencies. - Maintenance -
vanilla-gantt.d.ts,docs/vanilla-gantt/(newgetting-started.md), theproject-tasks-jssample and the Node, type and Playwright suites updated.
Version 1.0.0
- Added (
vanilla-gantt) - first release: the<vn-gantt>custom element shows a task tree as bars on a timeline, with an embedded<vn-grid>in tree mode as the task list. Includes a virtualized timeline, task dependencies (links), task moving with push, task selection and hover synced with the grid, keyboard scrolling, tooltips, a splitter between the panes, themes (themes/vn-gantt-default.css,themes/vn-gantt-default-dark.css), a single-filevanilla-gantt.bundle.js, and hand-authoredvanilla-gantt.d.ts. - Maintenance -
docs/vanilla-gantt/and theproject-tasks-jssample added.