How to create a vertical timeline component in React

In this article, we will show you how to create a vertical timeline component in React. Here we’ll use the NPM Package to draw a vertical timeline in React component.

Demo Application

Output - How to create a vertical timeline component in React - Clue Mediator
Output – How to create a vertical timeline component in React – Clue Mediator

Package Version

react
^17.0.2
react-vertical-timeline-component
^3.5.2
@fortawesome/react-fontawesome
^0.1.18
@fortawesome/free-solid-svg-icons
^6.1.1

File Structure

  • react-vertical-timeline-example
    • node_modules
    • public
      • index.html
    • src
      • App.js
      • index.css
      • index.js
    • package-lock.json
    • package.json
    • README.md

Steps to create a vertical timeline component

  1. Install dependency
  2. Prepare data to render in timeline
  3. Render timeline component
  4. Output

1. Install dependency

Here, we’ll use the react-vertical-timeline-component to add timeline in React application. Run the following command to install the dependency.

Also, we will add Font Awesome package to draw icons in the timeline. If you don’t know how to add Font Awesome to the React, refer to the article below.

How to add Font Awesome 5 in React

2. Prepare data to render in timeline

Let’s prepare the timeline data in form of the Array. We have also passed the icons object in the list to render the icon based on data.

3. Render timeline component

First, Import the package and CSS on top of the page. Use the following code.

Now simply use the following code to draw the timeline in React component.

4. Output

Let’s combine all code together and see how it looks.

App.js

Run the application and check the output in the browser.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

Demo & Source Code

GitHub Repository StackBlitz Project
If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *