Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hoseinh/react-analog-clock

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hoseinh/react-analog-clock

![NPM Downloads](https://img.shields.io/npm/dt/%40hoseinh%2Freact-analog-clock) ![NPM License](https://img.shields.io/npm/l/%40hoseinh%2Freact-analog-clock)

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
118
increased by114.55%
Maintainers
1
Weekly downloads
 
Created
Source

React Analog Clock Component

NPM Downloads NPM License

React Analog Clock is a customizable React component that displays an analog clock with various options for customization.

Check out the online demo For Examples.

Installation

You can install the @hoseinh/react-analog-clock package via npm:

npm install @hoseinh/react-analog-clock

Usage

All props for the AnalogClock component are completely optional, empowering users to tailor the clock's appearance and behavior to their specific preferences. The package offers a selection of five distinct clock faces through the "numbersType" prop (refer to the props table), while also providing the flexibility to define a completely custom clock face using the "customBg" prop.

import React from 'react';
import { AnalogClock } from '@hoseinh/react-analog-clock';

const MyClock = () => {
  return (
    <AnalogClock
      showMinuteHand={true}
      showSecondHand={true}
      showBorder={true}
      showHandBase={true}
      smooth={false}
      whiteNumbers={false}
      square={false}
      numbersType="numbersAndLines"
      borderColor="#000000"
      handBaseColor="#000000"
      handColor={{ hour: "#000000", minute: "#000000", second: "#e74c3c" }}
      handLength={{ hour: "65px", minute: "90px", second: "90px" }}
      handThickness={{ hour: "2px", minute: "2px", second: "2px" }}
      size="200px"
      backgroundColor="#ffffff"
    />
  );
};

export default MyClock;

You can show a static time and disable the clock's auto update by passing a "staticDate" Date object:

.
.
.
    <AnalogClock
      staticDate={new Date(2024, 0, 1, 12, 15, 0)}
    />
.
.
.

Props

PropDescriptionOptionsDefault Value
showMinuteHandWhether to show the minute handtrue, falsetrue
showSecondHandWhether to show the second handtrue, falsetrue
showBorderWhether to show the clock bordertrue, falsetrue
showHandBaseWhether to show the hand basetrue, falsetrue
smoothWhether to smoothly transition the hand movementtrue, falsefalse
whiteNumbersWhether to display white numbers on the clock facetrue, falsefalse
squareWhether the clock should be squaretrue, falsefalse
numbersTypeType of numbers to display on the clock face"numbers", "dots", "numbersAndLines", "lines", "roman""numbersAndLines"
borderColorColor of the clock borderAny valid CSS color value#000000
backgroundColorBackground color of the clockAny valid CSS color value#ffffff
handColorObject containing colors for each hand (hour, minute, second)-{ hour: "#000000", minute: "#000000", second: "#e74c3c" }
handLengthObject containing lengths for each hand (hour, minute, second)-{ hour: "65px", minute: "90px", second: "90px" }
handThicknessObject containing thickness for each hand (hour, minute, second)-{ hour: "2px", minute: "2px", second: "2px" }
handBaseColorColor of the hand baseAny valid CSS color value#000000
sizeSize of the clockAny valid CSS size value200px
staticDateStatic date to display on the clock which will disable clock's auto-updateDate object-
customBgCustom background image for the clock which will replace the default backgroundsURL to image file-

License

This project is licensed under the MIT License.

FAQs

Package last updated on 14 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc