Gantt Chart
A composable Gantt timeline with dependencies, progress, a Today reveal, panning and pinch zoom
- Relay SystemsHobby · $9/month
- Coral LabsTeam · $49/month
- Solstice RoboticsHobby · $9/month
- Obsidian StudioPro · $29/month
- Mira AIHobby → Pro · $29/month
- Lumen AITeam · $49/month
- Halcyon WorksPro Yearly · $290/year
- Brightline StudioTeam · $49/month
- Vertex StudioHobby · $9/month
- Atlas RoboticsPro · $29/month
- Kestrel LabsTeam · $49/month
- Tandem CloudTeam · $49/month
- Orbit HealthHobby · $9/month
- Quartz SystemsPro · $29/month
- Pyon AnalyticsHobby · $9/month
Installation
pnpm dlx shadcn@latest add @bklit/gantt-chartUsage
GanttChart is composed like every other bklit chart: a root that owns the data and the visible range, and parts that read it. Leave out any part you don't need.
import {
GanttAxis,
GanttBars,
GanttChart,
GanttGrid,
GanttLabels,
GanttToday,
GanttTooltip,
} from "@bklitui/ui/charts";
const data = [
{
id: "relay",
name: "Relay Systems",
segments: [
{ kind: "trial", start: "2026-11-16", end: "2026-11-30" },
{ kind: "active", start: "2026-11-30", end: null }, // null = still running
],
},
{ id: "coral", name: "Coral Labs", start: "2026-11-19", end: "2026-12-20" },
];
const config = {
trial: { label: "Trialing", pattern: "diagonal-up" },
active: { label: "Active", color: "var(--chart-1)" },
};
export function Subscriptions() {
return (
<GanttChart data={data} config={config}>
<GanttLabels title="Customer" />
<GanttAxis position="top" />
<GanttToday />
<GanttGrid />
<GanttBars />
<GanttAxis position="bottom" />
<GanttTooltip />
</GanttChart>
);
}Data
Rows are plain objects. A row is either one bar (start / end) or several phases (segments). Dates can be Dates, ISO strings ("2026-12-01" is read as a local date) or timestamps. end is exclusive (a segment from Dec 1 to Dec 3 covers Dec 1 and 2), a same-day segment still covers its day, and end: null means open-ended: the bar runs past the right edge.
interface Row {
id: string;
name: string;
start?: Date | string | number;
end?: Date | string | number | null;
segments?: { start; end: … | null; kind?: string; progress?: number }[]; // wins over start/end
progress?: number; // 0–1, spread over the row's span
dependencies?: Array<string | { id: string; type?: "FS" | "SS" | "FF" | "SF" }>;
// …any fields your labels / tooltip need, available as `row.datum`
}Different field names? Map them with idKey, nameKey, startKey, endKey, segmentsKey, progressKey and dependenciesKey, the same way xDataKey works on the cartesian charts.
Dependencies and progress
- DiscoveryResearch
- WireframesDesign
- Billing APIPlatform
- Visual designDesign
- FrontendWeb
- DocsDevRel
- QA passQuality
- LaunchMarketing
A row's dependencies name its predecessors by id. A plain string is finish → start; pass { id, type } for start → start ("SS"), finish → finish ("FF") or start → finish ("SF"). GanttDependencies draws them as SVG paths, recomputed on every zoom frame without re-rendering. Put it before GanttBars so links pass behind other rows' bars. Hovering a row brightens its links and fades the rest.
<GanttDependencies corner="round" cornerRadius={6} /> {/* step, rounded corners */}
<GanttDependencies corner="bevel" /> {/* step, angled (chamfered) corners */}
<GanttDependencies corner="miter" /> {/* step, square corners */}
<GanttDependencies curve="bump" /> {/* smooth S-curves */}
<GanttDependencies strokeDasharray="4 4" /> {/* dashed; selected ones flow */}
<GanttDependencies markerEnd="none" /> {/* no arrowheads */}Selecting and connecting
Click a bar to select it. Each segment is its own bar, so a row with three phases has three selectable bars. The selected bar gets a foreground border, and the links attached to it switch to the active colour (the destructive red, like Deadline). Dashed links (strokeDasharray) also flow: their dashes march toward the connected bar. Clicking empty plot or pressing Escape clears the selection. Selection is uncontrolled by default; control it with selected / onSelectedChange ({ rowId, segment } | null), or turn it off with selectable={false}.
Links always run from the predecessor's end into the successor's start, drawing in with the intro once the rows in view have started.
Pass onConnect to GanttDependencies to let people draw dependencies. Hovering near a bar's start shows a small handle just before it ("Drag to add dependency"), drawn above the bars. Drag from it onto another bar to make that bar its predecessor (finish → start). The chart doesn't change your data; add the dependency in the callback:
const [tasks, setTasks] = useState(initialTasks);
<GanttDependencies
onConnect={({ source, target }) =>
setTasks((all) =>
all.map((t) =>
t.id === target
? { ...t, dependencies: [...(t.dependencies ?? []), source] }
: t
)
)
}
/>With onDisconnect, the selected bar's links get a small remove button halfway along each line; the callback gets the link to remove from your data.
Link colours come from two CSS variables, so a theme can restyle them without props:
:root {
--chart-link: oklch(0.55 0.01 260); /* resting links */
--chart-link-active: var(--chart-negative); /* selected links + remove button */
}Without them, links fall back to --chart-foreground and --chart-negative (the same red as Deadline). The selected bar's border uses the foreground colour.
progress (0–1) on a row is spread across the row's span; a segment's own progress wins. The done part keeps its fill and the rest fades to progressRemainingOpacity, with a sweep on intro. segmentLabel receives the row, so a check icon or a percentage is one line.
Weekends, deadlines and grid
GanttWeekends and GanttDeadline take the same props as Weekends and Deadline, positioned in the Gantt's day space so they slide with zooms and the Today reveal. Weekend bands fade out once a day is narrower than minDayWidth.
GanttGrid draws month, week and day lines (week and day fade in by density). fadeVertical (true, "top" or "bottom") fades them toward the edges, strokeDasharray ("3 3") makes them dashed, horizontal adds row dividers and stroke recolours every line.
<GanttWeekends fillType="pattern" pattern="diagonal-up" />
<GanttGrid fadeVertical strokeDasharray="3 3" />
<GanttDeadline date={freeze} fillType="gradient" label="Code freeze" />Bar fills
Each segment's kind looks up its style in config. A kind can be a solid colour, a gradient, a bklit pattern, an outline, or a mix. Layers paint fill → pattern → stroke. Patterns are drawn in user space, so they never stretch with the bar.
const config = {
trial: { label: "Trialing", pattern: "diagonal-up" },
active: { label: "Active", color: "color-mix(in oklab, var(--chart-foreground) 38%, transparent)" },
upgrade: { label: "Upgraded", gradient: { from: "var(--chart-2)", to: "var(--chart-1)" } },
scheduled: { label: "Scheduled", stroke: "var(--chart-foreground)", strokeStyle: "dashed" },
tentative: {
label: "Tentative",
pattern: "diagonal-down",
patternColor: "var(--chart-1)",
stroke: "var(--chart-1)",
strokeStyle: "dashed",
},
default: { color: "var(--chart-1)" }, // segments with no kind
} satisfies GanttConfig;- Billing v2Payments
- Usage alertsGrowth
- SSOPlatform
- Mobile appMobile
- Audit logPlatform
- OnboardingGrowth
| Key | Type | Description |
|---|---|---|
label | string | Legend and tooltip label. Default: the kind key |
color | string | Solid fill. With a pattern, it becomes a faint wash under it |
gradient | { from, to, angle? } | string | Linear gradient fill (wins over color). A CSS gradient string also works |
opacity | number | Fill opacity |
pattern | PatternPresetId | Any bklit pattern preset, drawn over the fill |
patternColor | string | Pattern colour. Default: color, else muted foreground |
patternScale | number | Pattern tile scale |
patternStrokeWidth | number | Line width for line presets. Default: 1.25 |
stroke | string | 1px outline |
strokeStyle | "solid" | "dashed" | Outline style |
className | string | Escape hatch on the segment element |
Today, scales and zoom
GanttToday puts a chip on the month row ("‹ Today · Dec 1"). Clicking it reveals the previous period: the previous week on the week scale, or back to the 1st of last month on the month scale. The right edge stays put. Revealed, the chip becomes a solid pill on a today line that runs unbroken through every row.
GanttScaleToggle switches between week (14 days) and month (28 days). Both animate the visible range and can interrupt each other: the Today reveal over 450ms (cubic-bezier(0.32, 0.72, 0, 1)), and a zoom faster, over 300ms with a strong ease-out (cubic-bezier(0.23, 1, 0.32, 1), the same curve as the toggle's sliding pill). Ticks never swap: they slide, and each tier (month / week / day) fades in by how many pixels its unit gets.
Both are controlled or uncontrolled, with React-style names:
| State | Controlled | Uncontrolled | Change |
|---|---|---|---|
| Zoom preset | scale | defaultScale ("month") | onScaleChange |
| Today reveal | revealed | defaultRevealed (false) | onRevealedChange |
Put your own toolbar outside the chart by controlling both:
- Relay Systems
- Coral Labs
- Solstice Robotics
- Obsidian Studio
- Mira AI
- Lumen AI
const [scale, setScale] = useState<GanttScaleName>("week");
const [revealed, setRevealed] = useState(false);
<GanttScaleToggle value={scale} onValueChange={setScale} />
<GanttChart scale={scale} onScaleChange={setScale} revealed={revealed} onRevealedChange={setRevealed} …>Labels column
GanttLabels is an optional row-header column. It stays aligned to the rows, blurs in with them and dims with the hover. What goes in it is up to you: the subscriptions example renders customer + plan, and the schedule example has no column at all. Its render prop gets the normalized row; your original object is on row.datum.
<GanttLabels<Customer> title="Customer" width={232}>
{(row) => (
<>
<GanttLabel>{row.name}</GanttLabel>
<GanttLabelDescription>{row.datum.plan}</GanttLabelDescription>
</>
)}
</GanttLabels>Plot only
Legend
There's no Gantt-specific legend. Use bklit's Legend with ganttLegendItems(config), and GanttLegendMarker to draw each kind's real fill (gradient, pattern, outline). Link it to the chart with highlightedKind, which dims every other kind:
const items = ganttLegendItems(config);
const [highlighted, setHighlighted] = useState<string | null>(null);
<Legend
items={items}
className="flex-row"
onHoverChange={(i) => setHighlighted(i === null ? null : items[i].kind)}
>
<LegendItem className="flex items-center gap-1.5">
<GanttLegendMarker config={config} />
<LegendLabel />
</LegendItem>
</Legend>
<GanttChart highlightedKind={highlighted} …>Or build anything from the hooks. useGantt() exposes config, rows, scale, setScale, revealed, setRevealed and the viewport motion values, and GanttSwatch renders any kind's fill on its own.
Hover
GanttTooltip is bklit's standard hover, made of the same parts as ChartTooltip: a crosshair line (TooltipIndicator), a rolling date pill (DateTicker) on the bottom axis, and a bubble (TooltipBox) beside the hovered row. Ticks on the bottom axis fade out near the pill, as on the other charts. Turn the pill off (showDatePill={false}) and the axis highlights the hovered day's tick instead (see the plot-only example). Pass content for your own bubble:
<GanttTooltip<Customer>
content={({ row, segment, date }) => (
<>
<TooltipHeader>{row.name}</TooltipHeader>
…
</>
)}
/>Panning and zooming
Swipe sideways on a trackpad, Shift + scroll, or drag the plot to move through time. A drag glides on with inertia. Panning stops a week past the first and last bars. Once today is out of view, the Today chip pins to the edge with its chevron pointing back; click it to glide back to today. Bars outside the view leave a small pill at the plot edge ("‹ Sep 23 to Oct 23", "Feb 3 to Mar 1 ›"), so there's always a hint that there's more to the left or right.
Pinch to zoom: a trackpad pinch (or Ctrl + scroll), a Safari gesture, or two fingers on a touch screen widens or narrows the visible range around the point between your fingers, from about a week to about six months. The response is damped so small pinches make small changes, and day, week and month labels fade in and out by density as you go. Picking Week or Month in the toggle resets the zoom. After any pan or pinch, the Today chip's first click glides back to today's view (no pan, no zoom), and the next one toggles the reveal as usual; a reveal always starts from today's view.
Ticks, gridlines and weekend bands only render around the visible range, re-snapped every two weeks as you pan, so a timeline spanning years costs the same as one month. Pass pannable={false} for a fixed view. The large-data example below spans nine months, so try panning into the future there.
Large data
2,000 tasks, with only the rows in view rendered. bodyHeight caps the rows area: rows scroll under fixed axes and a fixed Today line. rowWindow tells the chart which rows to render; the plot stays sized for every row, so the scrollbar is right. The chart doesn't bundle a virtualizer, so bring your own. Here, TanStack Virtual uses the chart's scrolling body (bodyRef) as its scroll element:
import { useVirtualizer } from "@tanstack/react-virtual";
const bodyRef = useRef<HTMLDivElement>(null);
const virtualizer = useVirtualizer({
count: tasks.length,
getScrollElement: () => bodyRef.current,
estimateSize: () => 36, // = rowHeight
overscan: 8,
});
const items = virtualizer.getVirtualItems();
const rowWindow = items.length
? { start: items[0].index, end: items.at(-1).index + 1 }
: { start: 0, end: 16 }; // before the first measure (SSR)
<GanttChart
data={tasks}
rowHeight={36}
bodyHeight={480}
bodyRef={bodyRef}
rowWindow={rowWindow}
>
…
</GanttChart>Only rows in the window render bars, labels and row dividers. Dependency links render when they cross the window. The intro plays for the rows on screen at load, and rows scrolled in later appear without it.
Hooks
| Hook | Returns |
|---|---|
useGantt() | rows, config, today, scale / setScale, revealed / setRevealed, t0 / t1 (viewport motion values, day offsets from today), pan (motion value, days) / panDirection / resetPan(), horizon (rendered day range), rowHeight, barHeight, plotWidth |
useGanttHover() | { row, day, x } | null, the hovered row index, day offset and plot x |
Pure helpers are exported for custom parts and tests: GANTT_SCALES, ganttScaleViewport, ganttTierTicks, ganttTierOpacity, ganttZoomRange, normalizeGanttRows, ganttLinkPath / ganttElbowPath, ganttSegmentProgress and ganttWeekendRuns.
Components
GanttChart
| Prop | Type | Default | Description |
|---|---|---|---|
data | T[] | required | Rows |
config | GanttConfig | {} | Segment kind → fill / label |
today | Date | string | number | the viewer's local day | Without it, the server renders a sized placeholder and the chart appears once the browser knows its local day. Pass a fixed date to render on the server |
scale / defaultScale / onScaleChange | "week" | "month" | "month" | Zoom preset |
revealed / defaultRevealed / onRevealedChange | boolean | false | Today reveal |
scales | GanttScaleName[] | all | Scales offered to the toggle |
rowHeight | number | 44 | Row height, px |
barHeight | number | 20 | Bar height, px |
highlightedKind | string | null | null | Dim every other kind |
animate | boolean | true | Play the intro (rows wipe in, staggered) |
bodyHeight | number | — | Max height of the rows area, px. Rows scroll under fixed axes |
bodyRef | Ref<HTMLDivElement> | — | The scrolling rows element (a virtualizer's scroll element) |
rowWindow | { start, end } | all rows | Render only rows [start, end) |
pannable | boolean | true | Trackpad / Shift + wheel / drag panning with inertia, bounded to the data, and pinch zoom |
selected / defaultSelected / onSelectedChange | { rowId, segment } | null | null | Selected bar (click one) |
selectable | boolean | true | Click a bar to select it |
idKey / nameKey / startKey / endKey / segmentsKey | string | field names | Map your fields |
Other div props (className, style, aria-*) pass through to the root.
GanttBars
| Prop | Type | Default | Description |
|---|---|---|---|
track | boolean | true | Rounded track hugging each row's bars |
trackPadding | number | 4 | Track padding, px. Track radius = radius + this |
radius | number | 5 | Segment corner radius |
gap | number | 3 | Gap between adjacent segments |
dimOnHover | boolean | true | Fade other rows while one is hovered |
startLabel | boolean | (row) => ReactNode | true | Label left of the bar (start date) |
endLabel | boolean | (row) => ReactNode | — | Label right of the bar |
segmentLabel | (segment, row) => ReactNode | — | Content inside a segment |
notches | (row) => Date[] | — | Thin marks inside segments (renewals, milestones) |
showProgress | boolean | true | Draw progress from the data |
progressRemainingOpacity | number | 0.35 | Opacity of the not-yet-done part |
GanttDependencies
| Prop | Type | Default | Description |
|---|---|---|---|
curve | "step" | "bump" | "step" | Orthogonal runs, or one smooth S-curve |
corner | "round" | "bevel" | "miter" | "round" | Elbow shape, named after SVG stroke-linejoin: curved, angled (45° chamfer) or square |
cornerRadius | number | 6 | How far each corner is cut back, px |
stub | number | 10 | Horizontal run out of / into a bar before turning |
stroke | string | var(--chart-link) | Line and marker colour |
strokeWidth | number | 1.5 | |
strokeOpacity | number | 0.5 | 1 on the hovered row's links |
strokeDasharray | string | solid | e.g. "4 3" |
strokeLinecap | "butt" | "round" | "square" | "round" | |
markerStart | "dot" | "none" | "none" | Marker on the predecessor |
markerEnd | "arrow" | "dot" | "none" | "arrow" | Marker on the successor |
markerSize | number | 6 | px |
gap | number | 3 | Match GanttBars gap so links meet bar edges |
highlightOnHover | boolean | true | Brighten the hovered row's links, fade the rest |
activeStroke | string | var(--chart-link-active) | Links attached to the selected bar |
activeStrokeDasharray | string | strokeDasharray | Dashes on the selected bar's links |
flow | boolean | true | A selected dashed link's dashes flow toward the successor (off under reduced motion) |
onConnect | ({ source, target, type }) => void | — | Show the connect handle before each bar's start; called when a drag ends on another bar |
onDisconnect | ({ source, target, type }) => void | — | Show a remove button at the middle of the selected bar's links |
GanttAxis
| Prop | Type | Default | Description |
|---|---|---|---|
position | "top" | "bottom" | "bottom" | Top hosts the month row and the Today chip |
tiers | ("month" | "week" | "day")[] | top ["month"], bottom ["week", "day"] | Tick tiers (density-faded) |
formatLabel | (date, tier) => string | — | Custom tick text |
hoverEffect | "auto" | "fade" | "highlight" | "none" | "auto" | Same as XAxis. fade hides labels under and near the date pill. highlight lights the hovered day's label (shown even when its tier is faded) and blends nearby labels. auto = fade with a date pill, else highlight (bottom axis) |
tickerHalfWidth | number | 50 | fade: half the pill width, px |
activeLabelColor / nearbyLabelColor | string | var(--chart-indicator-color) | highlight colours |
highlightRadius | number | 80 | highlight: blend distance, px |
GanttGrid, GanttToday, GanttScaleToggle, GanttTooltip
| Component | Props |
|---|---|
GanttGrid | tiers (default all three; week and day lines fade in by density), fadeVertical (boolean | "top" | "bottom"), strokeDasharray, stroke, horizontal |
GanttWeekends | Same as Weekends: weekendDays, fillType, fill, fillOpacity, pattern, patternScale, patternStrokeWidth, minDayWidth |
GanttDeadline | Same as Deadline: date, endDate, color, fillType, fade, fadeLength, stroke*, label, labelPosition … |
GanttToday | label ("Today"), showDate (true) |
GanttScaleToggle | value / onValueChange (optional; defaults to the chart's scale), scales, formatLabel |
GanttTooltip | content, showCrosshair, showDatePill, showBubble, datePillVariant, animate (false snaps the crosshair and pill to each day, no easing) |
GanttLabels | title, width (232), children render prop |
GanttHeader | Toolbar row inside the chart (title, toggle, legend) |
Accessibility
- The Today chip is a
buttonwhose accessible name starts with its visible text and says what a click does ("Today, show November", "Today, hide previous week"). GanttScaleToggleis afieldsetof toggle buttons (aria-pressed), and the arrow keys move between scales.- Status isn't colour-only: kinds can carry a pattern or an outline, and the tooltip names the status.
- Under
prefers-reduced-motionthe intro is skipped and every viewport change jumps.
See the charts gallery for more examples.