Components

Gantt

A Gantt chart component with drag-and-drop task scheduling, timeline zoom, custom markers, and sidebar navigation.

Client Only

Installation

pnpm dlx @docyrus/cli add @docyrus/ui-gantt
UI Primitives(2 components)
npx shadcn@latest add card context-menu
Required Packages(4 packages)
pnpm add @dnd-kit/core @dnd-kit/modifiers date-fns lodash

Usage

import {
  GanttProvider,
  GanttSidebar,
  GanttSidebarHeader,
  GanttSidebarGroup,
  GanttSidebarItem,
  GanttHeader,
  GanttContentHeader,
  GanttTimeline,
  GanttFeatureList,
  GanttFeatureListGroup,
  GanttFeatureRow,
  GanttFeatureItem,
  GanttFeatureItemCard,
  GanttFeatureDragHelper,
  GanttColumns,
  GanttColumn,
  GanttAddFeatureHelper,
  GanttToday,
  GanttMarker,
  GanttCreateMarkerTrigger
} from '@docyrus/ui/components/gantt';
import type { GanttFeature, GanttStatus, Range } from '@docyrus/ui/components/gantt';

const statuses: GanttStatus[] = [
  { id: 'todo', name: 'To Do', color: '#3b82f6' },
  { id: 'in-progress', name: 'In Progress', color: '#f59e0b' },
  { id: 'done', name: 'Done', color: '#22c55e' }
];

const features: GanttFeature[] = [
  {
    id: '1',
    name: 'Design system',
    startAt: new Date(2025, 0, 1),
    endAt: new Date(2025, 0, 15),
    status: statuses[0]
  }
];

<GanttProvider>
  <GanttSidebar>
    <GanttSidebarHeader>Tasks</GanttSidebarHeader>
    <GanttSidebarGroup name="Sprint 1">
      {features.map(f => (
        <GanttSidebarItem key={f.id} feature={f} />
      ))}
    </GanttSidebarGroup>
  </GanttSidebar>

  <div className="flex flex-col flex-1">
    <GanttHeader>
      <GanttContentHeader />
    </GanttHeader>

    <GanttTimeline>
      <GanttColumns>
        {columns.map(col => (
          <GanttColumn key={col.id} {...col} />
        ))}
      </GanttColumns>
      <GanttFeatureList>
        <GanttFeatureListGroup>
          {features.map(f => (
            <GanttFeatureRow key={f.id} feature={f}>
              <GanttFeatureItem feature={f}>
                <GanttFeatureItemCard feature={f} />
              </GanttFeatureItem>
            </GanttFeatureRow>
          ))}
        </GanttFeatureListGroup>
      </GanttFeatureList>
      <GanttToday />
    </GanttTimeline>
  </div>

  <GanttFeatureDragHelper />
</GanttProvider>

Components

ComponentDescription
GanttProviderRoot context provider. Manages zoom, range, scroll, and drag state.
GanttSidebarLeft sidebar container for task list navigation.
GanttSidebarHeaderSidebar header area.
GanttSidebarGroupNamed group within the sidebar.
GanttSidebarItemSingle task row in the sidebar.
GanttHeaderTop header container area.
GanttContentHeaderTimeline column headers (year/month/day labels based on range).
GanttTimelineScrollable timeline area with DnD support.
GanttFeatureListContainer for feature rows.
GanttFeatureListGroupGroup within the feature list.
GanttFeatureRowRow container for a single feature.
GanttFeatureItemDraggable feature bar within a row.
GanttFeatureItemCardVisual card for the feature (colored by status).
GanttFeatureDragHelperDrag preview overlay during drag operations.
GanttColumnsBackground column grid for the timeline.
GanttColumnSingle column in the grid.
GanttAddFeatureHelperQuick-add button that appears on column hover.
GanttTodayToday marker line on the timeline.
GanttMarkerCustom timeline marker (milestones, deadlines).
GanttCreateMarkerTriggerButton to create a new marker at a date.

API Reference

GanttProvider

PropTypeDefaultDescription
zoomnumber—Zoom level controlling column density.
rangeRange—Timeline granularity ('daily', 'monthly', 'quarterly').
columnWidthnumber—Pixel width per column.
sidebarWidthnumber—Sidebar width in pixels.
headerHeightnumber—Header height in pixels.
rowHeightnumber—Row height in pixels.
onAddItem(date: Date) => void—Called when quick-add is triggered.
placeholderLengthnumber—Default duration for new tasks.
timelineDataTimelineData—Date structure for timeline columns.

GanttSidebarGroup

PropTypeDefaultDescription
namestring—Group label displayed in the sidebar.
classNamestring—Additional CSS classes.

GanttSidebarItem

PropTypeDefaultDescription
featureGanttFeature—Task data to display.
classNamestring—Additional CSS classes.

GanttFeatureItem

PropTypeDefaultDescription
featureGanttFeature—Task data for positioning and drag.
selectedboolean—Highlight state.
onSelect(feature: GanttFeature) => void—Selection callback.
onDragEnd(feature: GanttFeature, delta: Date) => void—Called after drag with new date.

GanttFeatureItemCard

PropTypeDefaultDescription
featureGanttFeature—Task data (status color, name).
classNamestring—Additional CSS classes.

GanttMarker

PropTypeDefaultDescription
idstring—Unique marker identifier.
dateDate—Marker position on the timeline.
labelstring—Marker label text.
classNamestring—Additional CSS classes.

Type Reference

GanttFeature

FieldTypeDescription
idstringUnique identifier.
namestringTask name.
startAtDateTask start date.
endAtDateTask end date.
statusGanttStatusCurrent status with color.
lanestringOptional lane/swimlane identifier.

GanttStatus

FieldTypeDescription
idstringUnique identifier.
namestringDisplay name.
colorstringHex color for the status.

Range

'daily' | 'monthly' | 'quarterly'

TimelineData

type TimelineData = Array<{
  year: number;
  quarters: Array<{
    months: Array<{ days: number }>;
  }>;
}>;

On this page