Skip to content

Timeline

KeyAction
/ kMove selection up one lane
/ jMove selection down one lane
/ hScroll timeline left
/ lScroll timeline right
Home / gJump to first lane, scroll to start
End / GJump to last lane
Ctrl+DHalf-page down (lanes)
Ctrl+UHalf-page up (lanes)
+ / =Zoom in (1.2×)
-Zoom out (0.8×)
0Reset zoom and scroll to default
EnterSelect lane (fires onSelect)

Each TimelineLane has a name and a list of TimelineItem entries with start/end times. The timeline renders all items for each lane in a single row:

tl := components.NewTimeline()
tl.SetLanes([]components.TimelineLane{
{
Name: "Build",
Items: []components.TimelineItem{
{Label: "compile", Start: t0, End: t1},
{Label: "test", Start: t1, End: t2},
},
},
})
Timeline preview

Timeline displays data as a horizontal Gantt-style timeline. Each lane represents a time-bounded item with status-based coloring.

Constructor func NewTimeline() *Timeline

Usage

start := time.Date(2026, 1, 1, 9, 0, 0, 0, time.UTC)
mid := start.Add(2 * time.Hour)
end := start.Add(4 * time.Hour)
tl := components.NewTimeline().
SetLanes([]components.TimelineLane{
{ID: "build", Name: "Build", StartTime: start, EndTime: &mid},
{ID: "test", Name: "Test", StartTime: mid, EndTime: &end},
}).
SetLabelWidth(12).
SetShowLegend(true)
tl.SetTimeRange(start, end)
fmt.Println(tl != nil)

Methods

Method Signature Description
AddLane func (t *Timeline) AddLane(lane TimelineLane) *Timeline AddLane adds a single lane to the timeline.
ClearLanes func (t *Timeline) ClearLanes() *Timeline ClearLanes removes all lanes.
GetLaneCount func (t *Timeline) GetLaneCount() int GetLaneCount returns the number of lanes.
GetSelectedLane func (t *Timeline) GetSelectedLane() *TimelineLane GetSelectedLane returns the currently selected lane, or nil if none.
SetBarStyleFn func (t *Timeline) SetBarStyleFn(fn func(status *theme.Status) (rune, tcell.Color)) *Timeline SetBarStyleFn sets a custom function for determining bar character and color. If not set, uses the Status.Color() for coloring.
SetLabelWidth func (t *Timeline) SetLabelWidth(width int) *Timeline SetLabelWidth sets the width of the label column.
SetLanes func (t *Timeline) SetLanes(lanes []TimelineLane) *Timeline SetLanes sets the timeline lanes.
SetOnSelect func (t *Timeline) SetOnSelect(fn func(lane *TimelineLane)) *Timeline SetOnSelect sets the callback for lane selection.
SetShowLegend func (t *Timeline) SetShowLegend(show bool) *Timeline SetShowLegend enables/disables the legend display.
SetTimeRange func (t *Timeline) SetTimeRange(start, end time.Time) *Timeline SetTimeRange manually sets the time range for the timeline. If not called, the range is calculated from lane data.
SetZoom func (t *Timeline) SetZoom(level float64) *Timeline SetZoom sets the zoom level.
Zoom func (t *Timeline) Zoom() float64 Zoom returns the current zoom level.

Types

type TimelineLane struct TimelineLane represents a horizontal lane in the timeline.
FieldTypeDescription
ID string Unique identifier
Name string Display name
Status *theme.Status Typed status for color/icon
StartTime time.Time When the lane starts
EndTime *time.Time When the lane ends (nil = ongoing)
Data any Optional user data