Tasks
A task is the fundamental unit of a FluxGantt chart. You describe tasks with a TaskInput
when constructing the chart (or when calling addTask); the store stamps the missing
bookkeeping fields and hands you back a full Task.
TaskInput — what you provide
import { toTaskId } from '@fluxgantt/core';
import type { TaskInput } from '@fluxgantt/core';
const input: TaskInput = {
id: toTaskId('build'), // optional — auto-generated when omitted
name: 'Build',
start: '2026-08-05', // DateInput: ISO string | Date | Temporal.PlainDate | Temporal.ZonedDateTime
end: '2026-08-10',
progress: 0.6, // required, 0..1
type: 'task', // required: 'task' | 'summary' | 'milestone' | 'project'
};TaskInput is Omit<Task, 'id' | 'createdAt' | 'updatedAt'> & { id?: TaskId }. That means:
name,start,end,progress,typeare required. There is no default fortypeorprogress— you supply them on every task (a milestone still needsprogressand atype: 'milestone').idis optional. Omit it and the store generates atask-<uuid>. Supply it viatoTaskId('build')so you can reference the task later (in dependencies,getTask, etc.).
Optional fields
| Field | Type | Notes |
|---|---|---|
id | TaskId | Auto-generated when omitted. Brand a string with toTaskId. |
duration | number | Working hours. Derived from start/end when omitted. |
priority | number | Lower = higher priority (used by Pro resource leveling). |
parent | TaskId | Groups this task under a summary/parent — see Hierarchy. |
constraint | TaskConstraint | A scheduling constraint, discriminated by kind. |
notes | string | Free-form text. Treated as untrusted when rendered. |
color | string | Whitelist-validated (valid CSS color) before it reaches the DOM. |
meta | Record<string, unknown> | Free-form user data. Untrusted when displayed. |
Task — what you get back
addTask (and the getters) return a full Task, which adds the store-managed fields:
const task = gantt.addTask(input);
task.id; // TaskId (branded)
task.createdAt; // Date
task.updatedAt; // DateTask kinds
type: TaskKind is one of:
task— a normal bar.milestone— a zero-duration marker (rendered as a diamond); use equalstart/end.summary— a roll-up bar spanning its children (see Hierarchy).project— the top-level roll-up.
Branded IDs
TaskId is string & { readonly __brand: 'TaskId' }. A plain string is not assignable to
it, which is what stops you passing a DependencyId (or an arbitrary string) where a TaskId
belongs. Create one at the boundary with toTaskId(string) — you never write as TaskId.
import { toTaskId } from '@fluxgantt/core';
const id = toTaskId('build'); // TaskIdMutating tasks
All of these return the updated Task and emit the matching event:
gantt.addTask(input); // → task:added
gantt.updateTask(id, { name: 'Rebuild' }); // → task:* per changed field
gantt.moveTask(id, '2026-08-06'); // → task:moved
gantt.resizeTask(id, 24); // 24 working hours → task:resized
gantt.setProgress(id, 0.75); // → task:progressed
gantt.removeTask(id); // → task:removed (cascades descendants)See the API Reference for full signatures.