Getting Started with Bryntum Gantt in JavaScript with npm package manager
Try JavaScript demos
Bryntum Gantt is delivered with a variety of JavaScript demo applications showing its functionality.
Version requirements
Minimum supported:
- JavaScript: `` or higher
- TypeScript:
3.6.0or higher (for TypeScript application) - Vite
4.0.0or higher (for application build with Vite)
Recommended:
- JavaScript: `` or higher
- TypeScript:
4.0.0or higher (for TypeScript application) - Vite
5.0.0or higher (for application build with Vite)
Create JavaScript application
In this guide we will explain how to get started using the npm CLI. If you prefer to not use npm, please visit the dedicated Quick Start here.
To get started, the broad steps are as follows:
- Access to npm registry
- Create Application
- Bryntum bundles
- Install component
- Add component to Application
- Apply styles
- Run the application
The application we are about to build together is pretty simple, and will look like the live demo below:
const gantt = new Gantt({ appendTo : targetElement, autoHeight : true, columns : [ { type : 'name', field : 'name', text : 'Name' } ], tasks : [ { id : 1, name : 'Documentation Project', expanded : true, children : [ { id : 2, name : 'Preparation', expanded : true, children : [ { id : 6, name : 'Proof-read docs', startDate : '2026-01-02', endDate : '2026-01-09' }, { id : 3, name : 'Release docs', startDate : '2026-01-09', endDate : '2026-01-10' } ] }, { id : 4, name : 'Development', expanded : true, children : [ { id : 7, name : 'Write API docs', startDate : '2026-01-05', endDate : '2026-01-12' }, { id : 8, name : 'Write tutorials', startDate : '2026-01-10', endDate : '2026-01-16' }, { id : 9, name : 'Create examples', startDate : '2026-01-12', endDate : '2026-01-18' } ] }, { id : 5, name : 'Review & Release', expanded : true, children : [ { id : 10, name : 'Team review', startDate : '2026-01-18', endDate : '2026-01-20' }, { id : 11, name : 'Final approval', startDate : '2026-01-20', endDate : '2026-01-21' }, { id : 12, name : 'Public release', startDate : '2026-01-22', endDate : '2026-01-22' } ] } ] } ], dependencies : [ { fromTask : 6, toTask : 3 }, { fromTask : 7, toTask : 8 }, { fromTask : 8, toTask : 9 }, { fromTask : 9, toTask : 10 }, { fromTask : 10, toTask : 11 }, { fromTask : 11, toTask : 12 } ], startDate : new Date(2026, 0, 1), endDate : new Date(2026, 0, 30) }); Access to npm registry
You can try out Bryntum components for free using our public Bryntum trial packages. If you have a Bryntum license, please refer to our Npm Repository Guide to access the private Bryntum repository.
Create Application
To create an application, we will use Vitejs and choose vanilla JavaScript.
First, execute the vite command:
npm create vite@latest my-gantt-app -- --template vanilla
It will generate a vanilla JavaScript boilerplate. Next, install dependencies:
cd my-gantt-app
npm install
Open the project folder and delete counter.js, we don't need it in our case.
Install component
From your terminal, update project dependencies using the following commands:
npm install @bryntum/gantt@npm:@bryntum/gantt-trial@7.3.0
npm install @bryntum/gantt@7.3.0
Add component to Application
Once you have project set up, you can proceed with configuring your Gantt.
Delete the counter.js and replace your main.js with the following code:
import { Gantt } from '@bryntum/gantt';
import './style.css';
const gantt = new Gantt({
appendTo : 'app',
startDate : new Date(2022, 0, 1),
endDate : new Date(2022, 0, 10),
columns : [
{ type : 'name', width : 160 }
],
project : {
// Automatically introduces a `startnoearlier` constraint for tasks that (a) have no predecessors,
// (b) do not use constraints and (c) aren't `manuallyScheduled`
autoSetConstraints : true,
tasks : [
{
id : 1,
name : 'Documentation Project',
expanded : true,
children : [
{
id : 2,
name : 'Preparation',
expanded : true,
children : [
{ id : 6, name : 'Proof-read docs', startDate : '2026-01-02', endDate : '2026-01-09' },
{ id : 3, name : 'Release docs', startDate : '2026-01-09', endDate : '2026-01-10' }
]
},
{
id : 4,
name : 'Development',
expanded : true,
children : [
{ id : 7, name : 'Write API docs', startDate : '2026-01-05', endDate : '2026-01-12' },
{ id : 8, name : 'Write tutorials', startDate : '2026-01-10', endDate : '2026-01-16' },
{ id : 9, name : 'Create examples', startDate : '2026-01-12', endDate : '2026-01-18' }
]
},
{
id : 5,
name : 'Review & Release',
expanded : true,
children : [
{ id : 10, name : 'Team review', startDate : '2026-01-18', endDate : '2026-01-20' },
{ id : 11, name : 'Final approval', startDate : '2026-01-20', endDate : '2026-01-21' },
{ id : 12, name : 'Public release', startDate : '2026-01-22', endDate : '2026-01-22' }
]
}
]
}
],
dependencies : [
{ fromTask : 6, toTask : 3 },
{ fromTask : 7, toTask : 8 },
{ fromTask : 8, toTask : 9 },
{ fromTask : 9, toTask : 10 },
{ fromTask : 10, toTask : 11 },
{ fromTask : 11, toTask : 12 }
]
}
});
Here we are providing inline data, you can learn more about how we manage data using Store in this guide.
The code above sets up a basic project structure, defining several tasks and establishing dependencies between them.
Bryntum Gantt schedules project tasks with consideration for dependencies, constraints, and calendar configurations. For a detailed introduction to the Bryntum Gantt project entity, please see the data guide.
startDate and endDate configs passed to the Gantt instance denote the currently accessible timespan. autoSetConstraints to true in the ProjectModel configuration. Learn more about how to use EcmaScript modules here.
If you want to discover how flexible the Bryntum Gantt Component is, please explore the API documentation.
Apply styles
Stylesheets
The following CSS files are provided with the Bryntum npm packages:
| File | Contents |
|---|---|
gantt.css |
Structural CSS |
svalbard-light.css |
Svalbard Light theme |
svalbard-dark.css |
Svalbard Dark theme |
visby-light.css |
Visby Light theme |
visby-dark.css |
Visby Dark theme |
stockholm-light.css |
Stockholm Light theme |
stockholm-dark.css |
Stockholm Dark theme |
material3-light.css |
Material3 Light theme |
material3-dark.css |
Material3 Dark theme |
fluent2-light.css |
Fluent2 Light theme |
fluent2-dark.css |
Fluent2 Dark theme |
fontawesome/css/fontawesome.css |
Font Awesome Free base CSS |
fontawesome/css/solid.css |
Font Awesome Free solid icons |
You'll need to import the structural CSS and the preferred theme into your project for the Bryntum Gantt to render correctly, and if you are not replacing the icons used by the component, you will also need to include Font Awesome.
Remove the content of style.css and replace it with the following:
/* FontAwesome is used for icons */
@import "@bryntum/gantt/fontawesome/css/fontawesome.css";
@import "@bryntum/gantt/fontawesome/css/solid.css";
/* Structural CSS */
@import "@bryntum/gantt/gantt.css";
/* Bryntum theme of your choice */
@import "@bryntum/gantt/svalbard-light.css";
node_modules folder for simplicity in this code example. Consider using your preferred build tool instead. Sizing the component
By default, the Bryntum Gantt component is configured to occupy 100% of the parent DOM element with a min-height of 10em.
To display the component at the appropriate size, you can, for example, set parent components to take up the full height of the screen.
#app {
margin : 0;
display : flex;
flex-direction : column;
height : 100vh;
font-size : 14px;
}
There are many other solutions depending on the situation. Feel free to adapt the code above regarding your application layout. For more information on the topic, see this guide Sizing the component.
Run the application
Run the application by executing:
npm run dev
What to do next?
Tutorial
Now it is time to customize your application. To get familiar with the most common tasks developers perform, we have designed an engaging tutorial that we are excited to see you follow.
Learn about Data
Bryntum components often use multiple data collections and entities.
For a detailed explanation of how these elements interact, see our guide to displaying data in Bryntum Gantt.
Rendering and styling
In the rendering and styling guide you will learn how to customize the rendering of your Gantt.
Enabling features
Please refer to the enabling extra features guide to learn how to enhance your Gantt chart with additional functionality (such as displaying labels for the tasks).
Responsiveness
Gantt can be configured to work well on many different screen sizes. This is achieved by specifying different responsive "levels" (breakpoints) on Gantt and then having per level configurations on the columns.
If this is a concern now, visit the responsive guide to learn how to configure responsiveness.
Localization
Bryntum Gantt uses locales for translations of texts, date formats and such. This localization guide shows you how to use one of the locales that Bryntum Gantt ships with and how to create your own.