A timeline is a visual tool that helps represent data chronologically through lists, tables, or graphics. With several events occurring simultaneously, it becomes important to keep track of the events in the long run. With a timeline, we are able to keep track of key events and highlight them visually.
React provides several timeline libraries that you can use to document events in your web application. In this article, we’ll explore some of the best React timeline libraries, highlighting their features, and how to choose the best one for your use case.
Jump ahead:
- Types of timelines
- React timeline libraries
- React Vertical Timeline
- React-Chrono
- React Suite (rsuite)
- Frappe Gantt
- The Syncfusion Gantt component
- Choosing the right React timeline library
Types of timelines
You can represent the development of events using different formats of a timeline. Some of the formats include:
- Horizontal timeline: Visually represents events that occurred horizontally from left to right
- Vertical timeline: Visually represents events that occurred vertically from bottom to top
- Interactive timeline: Visually represents real-time occurrences, allowing one to scroll, zoom in and zoom out
- Gantt chart timeline: Visually represents occurrences in a spreadsheet-like template. This template usually contains horizontal bars with some kind of pointer that shows dependencies between the occurrences
- Roadmap timelines: Visually represents an organization’s goals, milestones, or deadlines
- Biographical timelines: Visually represent major events in a person’s life
React timeline libraries
The React community has provided several libraries that you can use to implement the different types of timelines based on the needs of your project. Let’s take a look at them now!
React Vertical Timeline
React Vertical Timeline is a simple and clean timeline component that allows you to create a vertical timeline for your React project.
Features
The React Vertical Timeline library is easy to install and integrate into your application. Its timeline elements are highly customizable and responsive. The library allows you to add custom icons and animations to your timeline, making it more visually appealing. You can also customize the scroll behavior.
The React Vertical Timeline library only limits you to working with vertical timelines. If your applications require other types of timelines, you might be required to install a different library.
Usage
Install React Vertical Timeline using the following command:
yarn add react-vertical-timeline-component
Then, make use of the library as shown:
import { VerticalTimeline, VerticalTimelineElement } from 'react-vertical-timeline-component'; .... const ReactVerticalTimelineComponent = () => { return <VerticalTimeline> {events.map(data => <VerticalElement data={data} />)} </VerticalTimeline> } const VerticalElement = ({ data }) => { return <VerticalTimelineElement className="vertical-timeline-element--work" contentStyle={{ background: 'rgb(33, 150, 243)', color: '#fff' }} contentArrowStyle={{ borderRight: '7px solid rgb(33, 150, 243)' }} date={`${getYear(data.start)} - ${data.end ? getYear(data.end) : "present"}`} iconStyle={{ background: 'rgb(33, 150, 243)', color: '#fff' }} icon={<WorkIcon />} > <h3 className="vertical-timeline-element-title">{data.position}</h3> <h4 className="vertical-timeline-element-subtitle">{data.company}</h4> <p>{data.description}</p> </VerticalTimelineElement> }
The library provides a VerticalTimeline
component that acts as a wrapper for your timeline and a VerticalTimelineElement
component that defines the appearance of the elements of your timeline.
The image below shows the implementation of a React Vertical Timeline using the React Vertical Timeline library:
React-Chrono
React-Chrono is a flexible, data-driven timeline library that allows developers to render timelines in three different modes: horizontal, vertical, and vertical alternating. It’s straightforward to use and highly customizable. Constant improvements on this library make it one of the best timeline libraries available.
Features
React-Chrono supports the implementation of vertical and horizontal libraries with slideshows that can be auto-played. Nested timelines can also be presented using this library.
React-Chrono also provides several props to customize your visual representation of events. It allows you to add videos and images to your timeline to make it more appealing. The library also supports keyboard accessibility, which provides a better user experience.
However, React-Chrono lacks interactivity; it does not support zooming, drag and drop, and resizing events.
Usage
Install React-Chrono using the following:
yarn add react-chrono
Then, use the library as shown:
import { Chrono } from "react-chrono"; .... <Chrono items={mappedEvents} mode="VERTICAL_ALTERNATING"></Chrono>
The items
prop expects data in the timeline item model, which can be found on the React-Chrono homepage. The mode expects either VERTICAL
, HORIZONTAL
, or VERTICAL_ALTERNATING
, and the default mode is set to HORIZONTAL
.
The package provides more props that can be used to customize your timeline. The images below show implementations of the three modes of timelines offered by React-Chrono:
React Suite
React Suite (rsuite) is a UI library that contains a variety of components that can be used to build a timeline. The library is highly customizable and has a variety of components that can be used to build a timeline. Building a timeline with rsuite is easy and straightforward.
Usage
Install rsuite using the following command:
yarn add rsuite
Import the library in your React component:
//React imports import React from 'react'; //React Suite imports import { Timeline, TimelineItem } from 'rsuite';
Then, create a React component and add the timeline elements:
// React Component called TimeLineComponent const TimeLineComponent = ()=> { return ( <Timeline> <Timeline.Item>16:27:41 Your order starts processing</Timeline.Item> <Timeline.Item>16:28:43 Your order to be ready for delivery</Timeline.Item> <Timeline.Item>16:28:45 Your parcel has been out of the library</Timeline.Item> </Timeline> ) }
This should result in a similar timeline to this:
Pros of rsuite:
- Comprehensive: React Suite provides a comprehensive set of UI components, which means developers can focus on building their application rather than creating UI elements from scratch
- Customizable: rsuite is highly customizable, with a range of options to change the appearance and behavior of each component
- Accessible: The library is built with accessibility in mind, with support for keyboard navigation, screen readers, and other accessibility features
- Easy to use: React Suite is easy to use, with a simple and intuitive API that makes it easy to get started
- Active development: React Suite is actively developed and maintained, with regular updates and bug fixes
Cons:
- Learning curve: While the library is easy to use, there may be a learning curve for developers who are new to React or web development
- Limited flexibility: React Suite is designed to provide a set of predefined components, so it may not be suitable for developers who need more flexibility in their UI design
- Code bloat: Using a library like React Suite can add extra code to your project, which may slow down your website or application
- Design constraints: The library has a predefined design, so it may be challenging to customize the components to match your website or application’s specific design requirements
- Compatibility issues: React Suite may not be compatible with all versions of React or other libraries, which may lead to compatibility issues when using multiple libraries together
Frappe Gantt
Frappe Gantt is an open source JavaScript library used to create simple, interactive, and modern Gantt charts.
Features
The Frappe Gantt library is easy to use and integrate. It offers a rich set of features that are customizable, including drag-and-drop functionality, and the ability to zoom and scale displayed events. When displaying events, you can define dependencies to understand their interrelations. You can also add a custom tooltip to each event to provide more information.
Frappe Gant tallows you to hook into some events and callbacks, allowing you to execute custom functions when they occur.
Usage
Install the library using the following:
yarn add frappe-gantt
If you experience a sass error, add sass
as a dev dependency as shown:
yarn add sass --save-dev
Then, make use of the Chrono library as shown:
import { useEffect } from "react"; import Gantt from 'frappe-gantt' import { events } from "../helpers/data"; import { FrappeGanttDataMap } from "../helpers/dataMaps"; const FrappeGantt = () => { const tasks = FrappeGanttDataMap(events); useEffect(() => { const gantt = new Gantt("#gantt", tasks); gantt.change_view_mode('Month') }, [tasks]) return <svg id="gantt"></svg> } export default FrappeGantt;
The code snippet above adds an SVG with the id gantt
to the DOM and uses the useEffect
Hook to initialize a new Gantt object with the desired events.
You can change the view mode of the chart using the change_view_mode
function. The styling and theme of the chart can be customized and custom event handlers can be added.
The image below shows a simple implementation of the Frappe Gantt library:
Learn more about the library in “How to build a Gantt Chart in JavaScript with Frappe Gantt.”
Syncfusion Gantt component
Syncfusion is a hub of feature-rich UI components for your application. It provides a Gantt chart component that you can use to build a Gantt timeline. However, this is a paid tool with a 30 day free trial.
Features
The Syncfusion Gantt component is highly performant and works seamlessly with various forms of data. The component’s themes are highly customizable and allow the addition of animations.
The component is responsive and allows interactivity, including editing and zooming. It’s built to support users from different locales. Despite the Syncfusion Gantt component being feature-rich, it might be expensive for developers working on passion projects.
The image below is an illustration of the Syncfusion Gantt component obtained from their home page. It displays occurrences in chronological order and also shows their dependencies using arrows:
Choosing the right React timeline library
There are several timeline libraries that each offer different features. When selecting a React timeline library, you should consider the following:
- Ease of use and integration. The library should be well-documented, with components that are easy to use in your application
- Customizability. The library should allow the addition of custom styles and elements to match the needs of your application
- Support and maintenance. The library should have regular updates to fix issues and should have a strong community or support center as well
- Compatibility. The library should be compatible with your React version or other libraries used in the application
- Amount and type of data. For large data, making use of a library that offers an interactive timeline would be the best choice. For project management, use a library that offers a Gantt chart timeline feature
These are just a few factors to look out for. Choosing a library will depend on the needs of your application.
Conclusion
React timeline libraries are essential tools when displaying a sequence of events in a visually appealing and interactive way.
In this article, we learned what a timeline is and the various types of timelines. We also explored some of the best React timeline libraries, their features, and their usage. Finally, we discussed key points to look at when selecting a React timeline library.
All of the code in this article is available on GitHub. I hope you enjoyed this article!
Get set up with LogRocket's modern React error tracking in minutes:
- Visit https://logrocket.com/signup/ to get an app ID.
- Install LogRocket via NPM or script tag.
LogRocket.init()
must be called client-side, not server-side. - (Optional) Install plugins for deeper integrations with your stack:
- Redux middleware
- ngrx middleware
- Vuex plugin
$ npm i --save logrocket
// Code:
import LogRocket from 'logrocket';
LogRocket.init('app/id');
Add to your HTML:
<script src="https://cdn.lr-ingest.com/LogRocket.min.js"></script>
<script>window.LogRocket && window.LogRocket.init('app/id');</script>