Gantt Chart
A full-featured project timeline component with drag & drop, hierarchical tasks, dependencies, multiple view modes, and rich customization.
Basic Usage
A minimal Gantt chart with default columns. Tasks auto-scroll to today on mount.
Basic Gantt Chart
import { GanttChart } from 'fluxo-ui';
import type { GanttTask } from 'fluxo-ui';
const tasks: GanttTask[] = [
{
id: '1',
name: 'Requirements Gathering',
start: new Date('2025-01-01'),
end: new Date('2025-01-07'),
progress: 100,
assignee: 'Alice',
},
{
id: '2',
name: 'UI Design',
start: new Date('2025-01-06'),
end: new Date('2025-01-14'),
progress: 60,
color: '#8b5cf6',
assignee: 'Bob',
},
// ...
];
function MyPage() {
return <GanttChart tasks={tasks} height={400} />;
}View Modes
Switch between Day, Week, Month, Quarter, and Year views. Can be controlled externally or left to the built-in toolbar.
Controlled View Mode
const [viewMode, setViewMode] = useState<GanttViewMode>('day');
<GanttChart
tasks={tasks}
height={400}
viewMode={viewMode}
onViewModeChange={setViewMode}
/>Hierarchical Tasks & Milestones
Nest child tasks inside a parent using the children array. Use type: 'group' for summary bars and type: 'milestone' for diamond markers. Groups can be collapsed.
Phases, Groups & Milestones
const tasks: GanttTask[] = [
{
id: 'phase-1',
name: 'Phase 1 — Discovery',
type: 'group',
start: new Date('2025-01-01'),
end: new Date('2025-01-14'),
progress: 90,
children: [
{ id: 'p1-t1', name: 'Stakeholder Interviews', start: '2025-01-01', end: '2025-01-05', progress: 100 },
{ id: 'p1-t2', name: 'Market Research', start: '2025-01-03', end: '2025-01-10', progress: 80 },
],
},
{
id: 'milestone-1',
name: 'Design Review',
type: 'milestone',
start: new Date('2025-01-14'),
end: new Date('2025-01-14'),
color: '#f59e0b',
},
];
<GanttChart tasks={tasks} height={400} />Task Dependencies
Connect tasks with dependency arrows using four relationship types: Finish-to-Start, Start-to-Start, Finish-to-Finish, and Start-to-Finish.
Dependency Arrows
const tasks: GanttTask[] = [
{
id: 'analysis',
name: 'Analysis',
start: '2025-01-01',
end: '2025-01-07',
progress: 100,
},
{
id: 'design',
name: 'Design',
start: '2025-01-08',
end: '2025-01-14',
progress: 60,
dependencies: [{ targetId: 'analysis', type: 'finish-to-start' }],
},
{
id: 'dev',
name: 'Development',
start: '2025-01-15',
end: '2025-01-28',
progress: 0,
dependencies: [{ targetId: 'design', type: 'finish-to-start' }],
},
];
// Supported dependency types:
// 'finish-to-start' | 'start-to-start' | 'finish-to-finish' | 'start-to-finish'Date Markers
Mark important dates (sprint boundaries, deadlines, releases) with labelled vertical lines.
Markers & Deadlines
import type { GanttMarker } from 'fluxo-ui';
const markers: GanttMarker[] = [
{ id: 'today', date: new Date(), label: 'Today', color: '#3b82f6' },
{ id: 'sprint', date: new Date('2025-02-07'), label: 'Sprint End', color: '#f59e0b' },
{ id: 'release', date: new Date('2025-02-28'), label: 'Release', color: '#10b981' },
];
<GanttChart tasks={tasks} markers={markers} height={400} />Drag & Drop / Resize
Drag task bars to move them or drag either handle to resize. Changes are reported via onTaskChange.
Interactive — Drag to Move, Handles to Resize
const [tasks, setTasks] = useState<GanttTask[]>(initialTasks);
const handleTaskChange = (e: GanttTaskChangeEvent) => {
setTasks(prev =>
prev.map(t => t.id === e.task.id
? { ...t, start: e.start, end: e.end }
: t
)
);
};
<GanttChart
tasks={tasks}
height={400}
allowTaskDrag={true} // default
allowTaskResize={true} // default
onTaskChange={handleTaskChange}
onTaskClick={({ task }) => console.log('clicked', task.name)}
onTaskDoubleClick={({ task }) => openEditModal(task)}
/>Creating Tasks by Drawing
Enable allowTaskCreate and let users draw new tasks by clicking and dragging on empty row space.
Draw New Tasks (drag on empty area)
const [tasks, setTasks] = useState<GanttTask[]>(initialTasks);
const handleTaskCreate = (e: GanttTaskCreateEvent) => {
const newTask: GanttTask = {
id: `task-${Date.now()}`,
name: 'New Task',
start: e.start,
end: e.end,
progress: 0,
};
setTasks(prev => [...prev, newTask]);
};
<GanttChart
tasks={tasks}
height={400}
allowTaskCreate={true}
onTaskCreate={handleTaskCreate}
/>Custom Columns
Define any number of columns with custom render templates. Access the full task object inside templates.
Custom Column Rendering
import type { GanttColumn } from 'fluxo-ui';
const columns: GanttColumn[] = [
{ field: 'name', headerText: 'Task', width: 200 },
{
field: 'assignee',
headerText: 'Owner',
width: 90,
align: 'center',
template: ({ value }) => (
<span style={{
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
width: 26, height: 26, borderRadius: '50%',
background: '#dbeafe', color: '#1d4ed8', fontWeight: 600, fontSize: 11,
}}>
{String(value ?? '?').charAt(0)}
</span>
),
},
{
field: 'progress',
headerText: '%',
width: 55,
align: 'center',
template: ({ value }) => (
<span style={{ color: value === 100 ? '#10b981' : '#6b7280', fontWeight: 600 }}>
{value}%
</span>
),
},
];
<GanttChart tasks={tasks} columns={columns} fieldsPanelWidth={360} height={400} />Sprint / Resource Planning
Use extra data fields with column templates to show metadata like priority or task type alongside the timeline.
Sprint Backlog View
const tasks: GanttTask[] = [
{
id: 'feature-auth',
name: 'Feature: Auth',
start: '2025-01-06',
end: '2025-01-14',
progress: 75,
assignee: 'Alice',
data: { priority: 'High', type: 'Dev' },
},
// ...
];
const columns: GanttColumn[] = [
{ field: 'name', headerText: 'Task', width: 180 },
{ field: 'assignee', headerText: 'Assignee', width: 80, align: 'center' },
{
field: 'data.priority',
headerText: 'Priority',
width: 75,
align: 'center',
template: ({ task }) => {
const priority = (task.data as any)?.priority;
const colors = { Critical: '#ef4444', High: '#f59e0b', Medium: '#3b82f6' };
return (
<span style={{
padding: '1px 6px', borderRadius: 10, fontSize: 10, fontWeight: 600,
background: `${colors[priority]}20`, color: colors[priority],
}}>
{priority}
</span>
);
},
},
];
// Mark weekends as holidays
const isHoliday = (date: Date) => date.getDay() === 0 || date.getDay() === 6;
<GanttChart
tasks={tasks}
columns={columns}
fieldsPanelWidth={360}
isHoliday={isHoliday}
markers={[
{ date: sprintStart, label: 'Sprint Start', color: '#3b82f6' },
{ date: sprintEnd, label: 'Sprint End', color: '#f59e0b' },
]}
height={420}
/>Quarterly / Annual View
Use viewMode="quarter" or "year" for roadmap-level planning across many months.
Quarterly Roadmap
<GanttChart
tasks={roadmapTasks}
viewMode="month" // or "quarter" | "year" for wider ranges
height={400}
columns={[{ field: 'name', headerText: 'Initiative', width: 200 }]}
/>Read-Only Mode
Set readOnly to disable all interactions. Useful for dashboards and reports.
Read-Only Gantt
<GanttChart
tasks={tasks}
height={400}
readOnly={true}
/>Timeline-Only View
Hide the left fields panel entirely with showFieldsPanel={false} for a compact timeline.
No Fields Panel
<GanttChart
tasks={tasks}
height={300}
showFieldsPanel={false}
/>Import
import { GanttChart } from 'fluxo-ui';
// Type imports
import type {
GanttTask,
GanttColumn,
GanttMarker,
GanttDependency,
GanttViewMode,
GanttTaskChangeEvent,
GanttTaskClickEvent,
GanttTaskCreateEvent,
GanttColumnTemplateProps,
TaskBarTemplateProps,
} from 'fluxo-ui';GanttChart Props
tasksreqGanttTask[]Array of task objects to display on the chart
tasksreqGanttTask[]Array of task objects to display on the chart
columnsGanttColumn[]"[{ field: 'name', headerText: 'Task Name', width: 200 }]"Column definitions for the left fields panel
columnsGanttColumn[]"[{ field: 'name', headerText: 'Task Name', width: 200 }]"Column definitions for the left fields panel
viewMode'day' | 'week' | 'month' | 'quarter' | 'year'"'day'"Controls how the timeline is rendered and grouped
viewMode'day' | 'week' | 'month' | 'quarter' | 'year'"'day'"Controls how the timeline is rendered and grouped
startDateDate | stringOverride the auto-computed start date of the visible range
startDateDate | stringOverride the auto-computed start date of the visible range
endDateDate | stringOverride the auto-computed end date of the visible range
endDateDate | stringOverride the auto-computed end date of the visible range
heightnumber | string"500"Total height of the Gantt chart container
heightnumber | string"500"Total height of the Gantt chart container
rowHeightnumber"40"Height of each task row in pixels
rowHeightnumber"40"Height of each task row in pixels
columnWidthnumberWidth of each timeline column. Defaults vary by view mode
columnWidthnumberWidth of each timeline column. Defaults vary by view mode
fieldsPanelWidthnumber | string"300"Width of the left-side fields/columns panel
fieldsPanelWidthnumber | string"300"Width of the left-side fields/columns panel
showFieldsPanelboolean"true"Toggle the left fields panel visibility
showFieldsPanelboolean"true"Toggle the left fields panel visibility
showTodayboolean"true"Highlight today with a vertical line and scroll to it on mount
showTodayboolean"true"Highlight today with a vertical line and scroll to it on mount
showDependenciesboolean"true"Render SVG dependency arrows between tasks
showDependenciesboolean"true"Render SVG dependency arrows between tasks
showProgressboolean"true"Render the progress overlay on task bars
showProgressboolean"true"Render the progress overlay on task bars
showTooltipboolean"true"Show hover tooltip with task details
showTooltipboolean"true"Show hover tooltip with task details
markersGanttMarker[]"[]"Vertical date markers (deadlines, milestones, events)
markersGanttMarker[]"[]"Vertical date markers (deadlines, milestones, events)
isHoliday(date: Date) => booleanCallback to determine if a date should be marked as a holiday
isHoliday(date: Date) => booleanCallback to determine if a date should be marked as a holiday
allowTaskDragboolean"true"Allow users to drag tasks to new dates
allowTaskDragboolean"true"Allow users to drag tasks to new dates
allowTaskResizeboolean"true"Allow users to resize task bars from either end
allowTaskResizeboolean"true"Allow users to resize task bars from either end
allowTaskCreateboolean"false"Allow users to drag on empty rows to create new tasks
allowTaskCreateboolean"false"Allow users to drag on empty rows to create new tasks
readOnlyboolean"false"Disable all drag, resize, and create interactions
readOnlyboolean"false"Disable all drag, resize, and create interactions
taskBarTemplate(props: TaskBarTemplateProps) => JSX.ElementCustom render function for task bar content
taskBarTemplate(props: TaskBarTemplateProps) => JSX.ElementCustom render function for task bar content
tooltipTemplate(task: GanttTask) => ReactNodeCustom render function for the hover tooltip
tooltipTemplate(task: GanttTask) => ReactNodeCustom render function for the hover tooltip
onTaskChange(event: GanttTaskChangeEvent) => voidFires when a task is moved or resized
onTaskChange(event: GanttTaskChangeEvent) => voidFires when a task is moved or resized
onTaskClick(event: GanttTaskClickEvent) => voidFires when a task bar is clicked
onTaskClick(event: GanttTaskClickEvent) => voidFires when a task bar is clicked
onTaskDoubleClick(event: GanttTaskClickEvent) => voidFires when a task bar is double-clicked
onTaskDoubleClick(event: GanttTaskClickEvent) => voidFires when a task bar is double-clicked
onTaskCreate(event: GanttTaskCreateEvent) => voidFires when a new task range is drawn (requires allowTaskCreate)
onTaskCreate(event: GanttTaskCreateEvent) => voidFires when a new task range is drawn (requires allowTaskCreate)
onViewModeChange(mode: GanttViewMode) => voidFires when the user switches the view mode
onViewModeChange(mode: GanttViewMode) => voidFires when the user switches the view mode
onExpandToggle(task: GanttTask, expanded: boolean) => voidFires when a group task is expanded or collapsed
onExpandToggle(task: GanttTask, expanded: boolean) => voidFires when a group task is expanded or collapsed
GanttTask Properties
idreqstringUnique identifier for the task
idreqstringUnique identifier for the task
namereqstringDisplay name of the task
namereqstringDisplay name of the task
startreqDate | stringStart date of the task
startreqDate | stringStart date of the task
endreqDate | stringEnd date of the task
endreqDate | stringEnd date of the task
progressnumber"0"Completion percentage (0-100)
progressnumber"0"Completion percentage (0-100)
type'task' | 'milestone' | 'group'"'task'"Determines visual style and behavior
type'task' | 'milestone' | 'group'"'task'"Determines visual style and behavior
colorstringCustom background color for the task bar
colorstringCustom background color for the task bar
textColorstringCustom text color inside the task bar
textColorstringCustom text color inside the task bar
dependenciesGanttDependency[]Array of dependency connections to other tasks
dependenciesGanttDependency[]Array of dependency connections to other tasks
childrenGanttTask[]Nested child tasks (makes this task a group/parent)
childrenGanttTask[]Nested child tasks (makes this task a group/parent)
collapsedboolean"false"Whether this group is initially collapsed
collapsedboolean"false"Whether this group is initially collapsed
assigneestringAssignee name shown in tooltip and custom columns
assigneestringAssignee name shown in tooltip and custom columns
draggableboolean"true"Override draggability for this specific task
draggableboolean"true"Override draggability for this specific task
resizableboolean"true"Override resizability for this specific task
resizableboolean"true"Override resizability for this specific task
tooltipReactNode | ((task: GanttTask) => ReactNode)Custom tooltip content for this task
tooltipReactNode | ((task: GanttTask) => ReactNode)Custom tooltip content for this task
dataRecord<string, unknown>Arbitrary extra data accessible in templates
dataRecord<string, unknown>Arbitrary extra data accessible in templates
Features
View Modes
5 built-in scales: Day, Week, Month, Quarter, Year with smart header grouping
Drag & Drop
Move tasks and resize from both ends with live visual feedback
Task Creation
Draw new tasks by clicking and dragging on empty row space
Hierarchical Tasks
Unlimited nesting depth with expand/collapse support
Task Types
Regular tasks, group/summary bars with caps, and diamond milestones
Dependencies
4 dependency types (FS, SS, FF, SF) rendered as curved SVG arrows
Progress Bars
Visual completion overlay on each task bar
Date Markers
Labelled vertical lines for deadlines, sprints, and events
Custom Columns
Any field from task data with full JSX template support
Custom Tooltips
Per-task or global tooltip template override
Holiday Support
isHoliday callback colors non-working days differently
Scroll Sync
Left and right panels stay vertically synchronized
Theming
Full dark/light + 5 brand themes via CSS variables — zero extra config
Responsive
Fields panel auto-hides on mobile, toolbar wraps on small screens
Accessibility
ARIA labels, keyboard focus, semantic roles on all interactive elements
Performance
React.memo, useMemo, useCallback throughout — handles large datasets