Gantt chart
Tasks on a timeline, with their progress, milestones and what each task waits for.
php
<?php
use Caelrik\Ui\Components\Gantt;
return [
Gantt::make('launch')->label('Product launch')->today('2026-11-20')
->task('research', 'User research', '2026-10-26', '2026-11-06', progress: 100, color: 'info')
->task('design', 'Design', '2026-11-02', '2026-11-13', progress: 100, depends: ['research'])
->task('build', 'Build the API', '2026-11-16', '2026-12-11', 40, ['design'], 'success')
->task('docs', 'Documentation', '2026-11-30', '2026-12-18', 0, ['design'], 'secondary')
->task('qa', 'Testing', '2026-12-07', '2026-12-18', depends: ['build'], color: 'warning')
->milestone('release', 'Release', '2026-12-21', depends: ['qa', 'docs'], color: 'danger'),
Gantt::make('sprint')->label('Sprint 12, by day')->scale('day')->today('2026-11-20')->dateFormat('D j')
->task('login', 'Login page', '2026-11-16', '2026-11-18', progress: 100)
->task('reset', 'Password reset', '2026-11-18', '2026-11-24', progress: 50, depends: ['login'])
->milestone('demo', 'Demo', '2026-11-25', depends: ['reset']),
];Usage
php
use Caelrik\Ui\Components\Gantt;
Gantt::make('launch')
->label('Product launch')
->scale('week') // day, week or month
->task('design', 'Design', '2026-11-02', '2026-11-13', progress: 100)
->task('build', 'Build', '2026-11-16', '2026-12-11', progress: 40, depends: ['design'], color: 'success')
->milestone('release', 'Release', '2026-12-14', depends: ['build']);task($id, $name, $start, $end, $progress, $depends, $color): both days are included. Dates areY-m-dstrings orDateTimeInterfaceobjects.$dependslists the ids of the tasks it waits for.milestone($id, $name, $date, $depends, $color): one day, drawn as a diamond.scale():day(28 px a day, weekends shaded),week(the default, from Monday) ormonth. The timeline starts and ends on whole days, weeks or months.today($date): the day of the red "today" line; the current day by default,nullto hide it.dateFormat(): how the start and end are written ("M j, Y" by default).labels()translates the column headers and "Milestone" (task,start,end,progress,depends,timeline,milestone).
Accessibility
- A real table named by the chart's label: task, start and end (
<time datetime>elements), progress, and the names of the tasks it depends on. The bars are drawn from the same data, and hidden from screen readers, so nothing is told by the drawing alone. - Milestones say "Milestone" in their progress cell, not only by their diamond shape.
- The timeline scrolls sideways in a named region reached with Tab and scrolled with the arrow keys. The task names stay in view, and the first scroll brings today's line into view.
- Bars are a light fill with a border in their color (3:1), the done part filled. The arrows between tasks need JavaScript, and are decorative: the "Depends on" column says the same.
- No inline styles: each row's bar is an SVG sized by attributes, so it lines up with its row and works under a strict Content Security Policy. In forced-colors mode it uses system colors.