Timeline visualizes a series of chained events.
import { TimelineModule } from 'primeng/timeline';
Timeline receives the events with the value property as a collection of arbitrary objects. In addition, content template is required to display the representation of an event. Example below is a sample events array that is used throughout the documentation.
<p-timeline [value]="events">
<ng-template pTemplate="content" let-event>
{{ event.status }}
</ng-template>
</p-timeline>
Content location relative the line is defined with the align property.
<p-timeline [value]="events" class="w-full md:w-20rem">
<ng-template pTemplate="content" let-event>
{{ event.status }}
</ng-template>
</p-timeline>
<p-timeline [value]="events" class="w-full md:w-20rem" align="right">
<ng-template pTemplate="content" let-event>
{{ event.status }}
</ng-template>
</p-timeline>
<p-timeline [value]="events" class="w-full md:w-20rem" align="alternate">
<ng-template pTemplate="content" let-event>
{{ event.status }}
</ng-template>
</p-timeline>
Additional content at the other side of the line can be provided with the opposite property.
<p-timeline [value]="events">
<ng-template pTemplate="content" let-event>
<small class="p-text-secondary">{{ event.date }}</small>
</ng-template>
<ng-template pTemplate="opposite" let-event>
{{ event.status }}
</ng-template>
</p-timeline>
Sample implementation with custom content and styled markers.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque quas!
<p-timeline [value]="events" align="alternate" styleClass="customized-timeline">
<ng-template pTemplate="marker" let-event>
<span class="custom-marker shadow-2" [style.backgroundColor]="event.color">
<i [ngClass]="event.icon"></i>
</span>
</ng-template>
<ng-template pTemplate="content" let-event>
<p-card [header]="event.status" [subheader]="event.date">
<img *ngIf="event.image" [src]="'https://primefaces.org/cdn/primeng/images/demo/product/' + event.image" [alt]="event.name" width="200" class="shadow-2" />
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate
neque quas!
</p>
<button pButton label="Read more" class="p-button-text"></button>
</p-card>
</ng-template>
</p-timeline>
TimeLine orientation is controlled with the layout property, default is vertical having horizontal as the alternative.
<p-timeline [value]="events" layout="horizontal" align="top">
<ng-template pTemplate="content" let-event>
{{ event }}
</ng-template>
</p-timeline>
<p-timeline [value]="events" layout="horizontal" align="bottom">
<ng-template pTemplate="content" let-event>
{{ event }}
</ng-template>
</p-timeline>
<p-timeline [value]="events" layout="horizontal" align="alternate">
<ng-template pTemplate="content" let-event>
{{ event }}
</ng-template>
<ng-template pTemplate="opposite" let-event><span> </span></ng-template>
</p-timeline>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-timeline | Container element. |
p-timeline-left | Container element when alignment is left. |
p-timeline-right | Container element when alignment is right. |
p-timeline-top | Container element when alignment is top. |
p-timeline-bottom | Container element when alignment is bottom. |
p-timeline-alternate | Container element when alignment is alternating. |
p-timeline-vertical | Container element of a vertical timeline. |
p-timeline-horizontal | Container element of a horizontal timeline. |
p-timeline-event | Event element. |
p-timeline-event-opposite | Opposite of an event content. |
p-timeline-event-content | Event content. |
p-timeline-event-separator | Separator element of an event. |
p-timeline-event-marker | Marker element of an event. |
p-timeline-event-connector | Connector element of an event. |
Timeline uses a semantic ordered list element to list the events. No specific role is enforced, still you may use any aria role and attributes as any valid attribute is passed to the list element.
Component does not include any interactive elements.
API defines helper props, events and others for the PrimeNG Timeline module.
Name | Type | Default | Description |
---|---|---|---|
value | array | null | An array of events to display. |
align | string | left | Position of the timeline bar relative to the content. Valid values are "left", "right for vertical layout and "top", "bottom" for horizontal layout. |
layout | string | vertical | Orientation of the timeline, valid values are "vertical" and "horizontal". |
style | string | null | Inline style of the component. |
styleClass | string | null | Style class of the component. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Parameters |
---|---|
opposite | $implicit: Data of the timeline event |
marker | $implicit: Data of the timeline event |
content | $implicit: Data of the timeline event |