Thursday, February 5, 2026
HomeLanguagesHow to add Analog Clock in ReactJS ?

How to add Analog Clock in ReactJS ?

In this article, we are going to learn how we can add Analog Clock in ReactJs. React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.

Approach: To add our Analog clock we are going to use the analog-clock-react package because it is powerful, lightweight, and fully customizable. After that, we will add our clock on our homepage using the installed package.

Create ReactJs Application: You can create a new ReactJs project using the below command:

npx create-react-app gfg

Install the required package: Now we will install the analog-clock-react package using the below command:

npm i analog-clock-react

Project Structure: It will look like this.

Adding Clock: In this example, we are going to add the clock on the homepage of our app using the package that we installed. For this, add the below content in the App.js file.

App.js




import AnalogClock from 'analog-clock-react';
   
export default function ReactClock() {
  let options = {
    width: "300px",
    border: true,
    borderColor: "#2e2e2e",
    baseColor: "#17a2b8",
    centerColor: "#459cff",
    centerBorderColor: "#ffffff",
    handColors: {
      second: "#d81c7a",
      minute: "#ffffff",
      hour: "#ffffff"
    }
  };
   
  return (
    <div>
      <h2>React Clock - neveropen</h2>
      <AnalogClock {...options} />
    </div>
  )
}


Explanation: In the above example first, we are importing the AnalogClock component from the analog-clock-react package. After that, we are creating an options variable and storing the settings in this variable. Then we are using our AnalogClock component to display the clock.

Steps to run the application: Run the below command in the terminal to run the app.

npm start

Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32479 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6853 POSTS0 COMMENTS
Nicole Veronica
11981 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12067 POSTS0 COMMENTS
Shaida Kate Naidoo
6991 POSTS0 COMMENTS
Ted Musemwa
7229 POSTS0 COMMENTS
Thapelo Manthata
6938 POSTS0 COMMENTS
Umr Jansen
6922 POSTS0 COMMENTS