Timeline

Events in order along an axis, such as an order history or an activity log, each with a marker and your content.

  • vig-timeline
Import
import { Timeline, TimelineContent } from '@vigdx/ui/timeline';

Basic

Pass items and an ng-template vigTimelineContent ; bind the same items to vigTimelineContentOf so let-event is typed. The context also has index , first , last and side . Put dates in <time datetime> elements.

  1. Ordered

    · Payment received.

  2. Processing

    · Packed at the warehouse.

  3. Shipped

    · Handed to the carrier.

  4. Delivered

    · Left at the front door.

Alignment and opposite content

align puts the content after the axis ( end , default), before it ( start ) or on alternating sides ( alternate ); sides are logical, so RTL mirrors them. A vigTimelineOpposite template fills the other side, e.g. with the date. The timeline measures its own width: below 32rem a two-sided timeline collapses to one side, the opposite content above the content. Being a size container, it fills its parent's width ( w-full ) instead of growing with its content: give it a width inside a flex row or an inline-block.

Content side

  1. Ordered

    Payment received.

  2. Processing

    Packed at the warehouse.

  3. Shipped

    Handed to the carrier.

  4. Delivered

    Left at the front door.

Horizontal

orientation="horizontal" shares the width between the events; the sides line up across events (a CSS subgrid). Below 32rem it turns vertical, so it never scrolls sideways.

  1. Ordered

  2. Processing

  3. Shipped

  4. Delivered

Custom markers

A vigTimelineMarker template replaces the default dot, e.g. with an icon; it is centered on the axis, a track --vig-timeline-marker-size wide (1.5em; set it to your markers' width so wide ones do not crowd the content), and kept visible to screen readers, so give a marker that carries meaning a text alternative.

  1. Ordered

    Payment received.

  2. Processing

    Packed at the warehouse.

  3. Shipped

    Handed to the carrier.

  4. Delivered

    Left at the front door.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="timeline"][data-part="root"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="timeline"]

Timeline styling hooks
Part Element data-state
root The <ol role="list"> . —
item One <li> event. —
opposite The vigTimelineOpposite content, across the axis. —
separator The axis cell: marker and connector. —
marker The default dot, or the wrapper of vigTimelineMarker . —
connector The line to the next event (a border). —
content The vigTimelineContent content. —

Accessibility

  • An ordered list: screen readers announce the number of events and each one's position. Opposite content comes first in each item, then the content, whatever side they are drawn on.
  • The default dot and the connectors are decorative and hidden from screen readers. They are borders in theme tokens (--color-primary, --color-border-strong), which forced-colors mode paints in CanvasText.
  • The timeline has no keyboard behaviour of its own; links and buttons in the content are reached with Tab.

API

Timeline

vig-timeline component

Events in order along an axis, each with a marker and a content template, and optionally opposite content such as its date.

Example :
<vig-timeline [items]="events">
  <ng-template vigTimelineContent [vigTimelineContentOf]="events" let-event>
    <h3>{{ event.title }}</h3>
  </ng-template>
  <ng-template vigTimelineOpposite [vigTimelineOppositeOf]="events" let-event>
    <time [attr.datetime]="event.iso">{{ event.date }}</time>
  </ng-template>
</vig-timeline>

An ordered list (<ol>): screen readers announce the count and each event's position. Markers and connectors are drawn with borders in theme tokens, which forced-colors mode repaints in system colors. Sides are logical, so the timeline mirrors under RTL. The timeline is a size container: below 32rem of its own width, two-sided layouts (alternate, or opposite content) collapse to one side with the opposite content above the content, and a horizontal timeline turns vertical. As a size container it does not size to its content: it fills the width of its parent (w-full), so give it a width in a shrink-to-fit parent (a flex row, an inline-block). The axis is --vig-timeline-marker-size wide (1.5em), so markers of any width stay centered on one line; set it to the width of custom markers.

Timeline props
Name Type Default Description
alignTimelineAlign'end'

Side of the axis the content takes: end (default), start or alternate.

itemsreadonly T[][]

The events, in order.

orientationTimelineOrientation'vertical'

vertical (default) or horizontal; a horizontal timeline narrower than 32rem turns vertical.

TimelineContent

ng-template[vigTimelineContent] directive

Content of each event of vig-timeline. Bind the items to vigTimelineContentOf to type let-event:

Example :
<ng-template vigTimelineContent [vigTimelineContentOf]="events" let-event>
  {{ event.title }}
</ng-template>
TimelineContent props
Name Type Default Description
vigTimelineContentOfreadonly T[] | null | undefinedundefined

Type-only: the items the template renders, so let-event is typed. Not read at runtime.

TimelineOpposite

ng-template[vigTimelineOpposite] directive

Content on the other side of the axis, such as the date of each event. Bind the items to vigTimelineOppositeOf to type let-event.

TimelineOpposite props
Name Type Default Description
vigTimelineOppositeOfreadonly T[] | null | undefinedundefined

Type-only: the items the template renders, so let-event is typed. Not read at runtime.

TimelineMarker

ng-template[vigTimelineMarker] directive

Custom marker on the axis (an icon, an avatar) in place of the default dot. Bind the items to vigTimelineMarkerOf to type let-event.

TimelineMarker props
Name Type Default Description
vigTimelineMarkerOfreadonly T[] | null | undefinedundefined

Type-only: the items the template renders, so let-event is typed. Not read at runtime.

Are you sure?