Skip to main content
Version: Next

Gantt API

import { Gantt } from '@editora/ui-react';

Props​

PropTypeDescription
autoSummarybooleanA parent's dates follow its children (the earliest start to the latest end), and so does its progress when it has none of its own.
barVariantGanttBarVariant
cascadebooleanMoving a parent moves everything under it by the same days (a read-only task stays put). Makes parent bars draggable.
columnsGanttColumn[]The task list's columns, in order. The name column is always first. Default: name, owner, dates, progress.
creatablebooleanShow a "+ Add task" button and let a double-click on empty timeline space ask for a task (onTaskCreate). Off in a readonly chart.
criticalPathbooleanMark the critical path from the links: the tasks with no slack on a tight chain of links (a task you flag critical stays).
fillbooleanFill the height of the container (which must have one): the toolbar keeps its height and the chart scrolls inside the rest.
filterTextstring
gridWidthnumberWidth of the task list in px. The user can also drag the splitter; see onGridResize.
headlessboolean
holidaysArray<string | Date | { date: string | Date; label?: string }>Dates that are not working days: 'YYYY-MM-DD' strings, Dates, or { date, label }. Shaded apart from nonWorkingDays, and the label names them in the day header.
initialScroll'today' | 'start'Where the chart opens: on 'today' (the default, when today is not on the first screen) or at the 'start'.
labelsPartial<GanttLabels>Translations: any subset of the labels.
linkablebooleanShow a dot beside each bar that you can drag onto another bar to ask for a dependency (onLinkCreate). Off in a readonly chart.
linksGanttLink[]
localestringBCP 47 locale for dates (month names, date formats, the week's first day). Defaults to the browser's.
maxHeightnumber | stringCap on the chart's height when it is not fill: a number (px) or a plain CSS length ('60vh', 'none'). Default 620px.
nonWorkingDaysnumber[] | 'weekend'Weekdays that are not working days (0 is Sunday), or 'weekend' for Saturday and Sunday. Shaded behind the rows where a day is wide enough to read.
onBeforeTaskChange(detail: GanttBeforeTaskChangeDetail, event: CustomEvent<GanttBeforeTaskChangeDetail>) => voidFired before a drag, resize or key changes dates. Call event.preventDefault() to refuse the change: nothing moves and onTaskChange does not fire.
onFilterChange(detail: { filter: string }, event: CustomEvent<{ filter: string }>) => void
onGridResize(detail: { width: number }, event: CustomEvent<{ width: number }>) => void
onLinkCreate(detail: GanttLinkCreateDetail, event: CustomEvent<GanttLinkCreateDetail>) => voidFired when a link is dropped on another task: the dot it started from (the source's start or end) and the half of the target it landed on give the type. The host adds the link.
onLinkDelete(detail: GanttLinkSelectDetail, event: CustomEvent<GanttLinkSelectDetail>) => voidFired when Delete or Backspace is pressed on a selected link (click a link to select it). The host removes it.
onLinkSelect(detail: GanttLinkSelectDetail, event: CustomEvent<GanttLinkSelectDetail>) => void
onSortChange(detail: { sort: GanttSort }, event: CustomEvent<{ sort: GanttSort }>) => void
onTaskChange(detail: GanttTaskChangeDetail, event: CustomEvent<GanttTaskChangeDetail>) => void
onTaskCreate(detail: GanttTaskCreateDetail, event: CustomEvent<GanttTaskCreateDetail>) => voidFired when the user asks for a new task (the Add button, or a double-click on empty timeline space). The host adds it.
onTaskDelete(detail: { id: string }, event: CustomEvent<{ id: string }>) => void
onTaskRename(detail: GanttTaskRenameDetail, event: CustomEvent<GanttTaskRenameDetail>) => voidFired when a name is edited in place (double-click it, or F2). Call event.preventDefault() to refuse. The component only keeps the new name until tasks is written again.
onTaskSelect(detail: { id: string }, event: CustomEvent<{ id: string }>) => void
onTaskToggle(detail: { id: string; open: boolean }, event: CustomEvent<{ id: string; open: boolean }>) => void
onZoomChange(detail: { zoom: GanttZoom }, event: CustomEvent<{ zoom: GanttZoom }>) => void
readonlyboolean
schedule'warn' | 'auto' | 'off'How dependencies are enforced: 'warn' (the default) draws a link whose target is too early in the danger style, 'auto' also pushes the tasks that follow a task that moves (later only, keeping their length), 'off' does neither.
showTodayboolean
showToolbarboolean
snap'day' | 'week' | 'month'How far a drag snaps: to whole 'day's (the default), 'week's or 'month's. Arrow keys still move a day at a time.
sortGanttSort
tasksGanttTask[]
variant'default' | 'contrast'
virtualizedboolean
weekStart0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week in the time header, as Date#getDay numbers it (0 is Sunday). Defaults to the locale's.
zoomGanttZoom

Also accepts the standard HTML and React props of the element it renders (className, style, id, aria-*, data-*, event handlers).

Element: <ui-gantt>​

Gantt renders the ui-gantt custom element from @editora/ui-core, which can also be used without React.

Attributes: auto-summary, bar-variant, cascade, columns, creatable, critical-path, fill, filter, grid-width, headless, holidays, labels, linkable, links, locale, max-height, non-working-days, readonly, schedule, show-today, show-toolbar, snap, sort, tasks, variant, week-start, zoom

Events: beforetaskchange, filterchange, gridresize, linkcreate, linkdelete, linkselect, sortchange, taskchange, taskcreate, taskdelete, taskrename, taskselect, tasktoggle, zoomchange