Styling

Customise the look of the timeline, items, and text.

TempisTimelineStyleOptions

PropertyTypeDescription
fontTempisTimelineFontDefault font settings (size, family, style, weight, lineHeight).
itemTempisTimelineItemStyleDefault item style overrides applied to all items.
gridColorstringColour for all grid lines, unit labels, group labels, and separators. Defaults to "#808080".

TempisTimelineFont

PropertyTypeDefaultDescription
familystring"Helvetica, Arial, sans-serif"Font family string.
sizenumber14Font size in pixels.
weightstring | number"normal"Font weight.
stylestring"normal"Font style (normal, italic).
lineHeightstringCSS line-height value.

TempisTimelineItemStyle

PropertyTypeDefaultDescription
backgroundColorstringpalette colourItem background colour.
fontColorstringItem label colour.
paddingnumberInner padding in pixels.
borderColorstringBorder colour.
borderThicknessnumberBorder width in pixels.
borderStyleTempisTimelineLineStyle"solid"Border line style: solid, dashed, dotted, dash-dot, or long-dash.
borderRadiusnumberCorner radius in pixels.

Style Precedence

Styles are resolved in the following order. Each level overrides the one below it:

1 Per-item style — highest priority, set on individual items
2 Category style — applied to all items in a category
3 Global style.item — from the constructor options
4 Library defaults — built-in fallback values

Example — Dark Theme

const timeline = new TempisTimeline('#canvas', {
  responsive: true,
  style: {
    font: { family: 'Inter, sans-serif', size: 13, weight: 500 },
    item: {
      backgroundColor: '#334155',
      fontColor: '#f1f5f9',
      borderColor: '#475569',
      borderThickness: 1,
      borderStyle: 'solid',
      borderRadius: 6,
      padding: 6
    }
  },
  items: [
    { id: 1, label: 'Item 1',    start: '2026-01-05', end: '2026-01-15' },
    { id: 2, label: 'Item 2', start: '2026-01-12', end: '2026-01-28' },
    {
      id: 3, label: 'Item 3 (Styled)', start: '2026-01-20', end: '2026-01-22',
      style: { backgroundColor: '#dc2626', borderStyle: 'dashed' }
    },
  ],
  range: { start: '2026-01-01', end: '2026-02-01', position: 'bottom' }
});

Grid Colour

Use gridColor to change the colour of all grid lines, axis labels, group labels, and separators. This is useful when embedding the timeline on coloured or dark backgrounds.

const timeline = new TempisTimeline('#canvas', {
  responsive: true,
  style: {
    gridColor: '#6366f1',
    item: { borderRadius: 6, fontColor: '#fff', padding: 8 }
  },
  items: [
    { id: 1, label: 'Item 1', start: '2026-02-01', end: '2026-02-14', grouping: 'Group 1' },
    { id: 2, label: 'Item 2', start: '2026-02-08', end: '2026-02-22', grouping: 'Group 1' },
    { id: 3, label: 'Item 3', start: '2026-02-05', end: '2026-02-18', grouping: 'Group 2' },
    { id: 4, label: 'Item 4', start: '2026-02-15', end: '2026-02-28', grouping: 'Group 2' },
  ],
  range: { start: '2026-01-25', end: '2026-03-05', position: 'bottom' }
});