Accessibility

Built-in keyboard navigation, ARIA attributes, and motion preferences.

Overview

Tempis Timeline includes accessibility support out of the box. The canvas element is made focusable and keyboard-navigable by default, with ARIA attributes for screen reader identification and automatic respect for the user's reduced motion preference.

Options

Accessibility options are grouped under the accessibility key in the timeline options.

import { TempisTimeline } from '@tempis/timeline';

const timeline = new TempisTimeline('#canvas', {
  accessibility: {
    ariaLabel: 'Project Schedule — Q1 2026',
    keyboard: true,
    keyboardPanStep: 0.1,
    keyboardZoomStep: 0.5
  },
  items: [
    { id: 1, label: 'Item 1', start: '2026-03-01', end: '2026-03-10' },
    { id: 2, label: 'Item 2', start: '2026-03-08', end: '2026-03-18' },
  ],
  range: { start: '2026-02-25', end: '2026-04-01', position: 'bottom' }
});
OptionTypeDefaultDescription
ariaLabelstringSets the aria-label attribute on the canvas. Provides a meaningful description for screen readers.
keyboardbooleantrueEnables keyboard navigation. When false, no tabindex or key handlers are added.
keyboardPanStepnumber0.1Fraction of the visible range to pan per arrow key press. 0.1 pans 10% of the visible range.
keyboardZoomStepnumber0.5Zoom intensity per +/- key press. Higher values zoom faster.

Keyboard Controls

When the canvas is focused (via Tab or click), the following keys are available:

KeyAction
Arrow LeftPan the timeline backward in time
Arrow RightPan the timeline forward in time
Arrow UpScroll the data view up (when content overflows)
Arrow DownScroll the data view down (when content overflows)
+ or =Zoom in (centered on the viewport)
- or _Zoom out (centered on the viewport)
Modifier key combinations (Ctrl, Meta, Alt) are not intercepted, so browser shortcuts continue to work normally.

Pan direction is automatically reversed when the timeline is in RTL mode.

ARIA Attributes

The timeline automatically applies the following attributes to the canvas element unless they are already set in your markup:

AttributeValuePurpose
role"img"Identifies the canvas as a graphical element for screen readers.
tabindex"0"Makes the canvas focusable via Tab. Only set when keyboard is enabled.
aria-labelUser-providedGives the canvas a descriptive name. Only set when ariaLabel is provided in options.
If you set role, tabindex, or aria-label directly on the canvas element in your HTML, the timeline will not overwrite them.

Reduced Motion

The timeline respects the prefers-reduced-motion: reduce media query. When the user has requested reduced motion in their operating system or browser settings, all animated transitions (such as focus({ animate: true })) are applied instantly without animation.

This behaviour is always active and cannot be disabled.

Disabling Keyboard Navigation

If your application handles its own keyboard shortcuts and the timeline's key handlers conflict, you can disable them:

const timeline = new TempisTimeline('#canvas', {
  accessibility: {
    keyboard: false
  },
  items: [
    { id: 1, label: 'Item 1', start: '2026-03-01', end: '2026-03-10' },
  ],
  range: { start: '2026-02-25', end: '2026-04-01', position: 'bottom' }
});

When keyboard is false, no tabindex attribute or key event handlers are added to the canvas. The role and aria-label attributes are still applied.