wojtekmaj / React Clock
Licence: mit
An analog clock for your React app.
Stars: ✭ 149
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to React Clock
simple-analog-clock
Simple clock view for displaying uh...time?
Stars: ✭ 24 (-83.89%)
Mutual labels: time, clock
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (+82.55%)
Mutual labels: time, clock
ElevenClock
ElevenClock: Customize Windows 11 taskbar clock
Stars: ✭ 1,494 (+902.68%)
Mutual labels: time, clock
Truetime Android
Android NTP time library. Get the true current time impervious to device clock time changes
Stars: ✭ 1,134 (+661.07%)
Mutual labels: time, clock
timestampy
🕒 Bunch of utilities useful when working with UNIX timestamps
Stars: ✭ 21 (-85.91%)
Mutual labels: time, clock
clock
High-resolution clock functions: monotonic, realtime, cputime.
Stars: ✭ 52 (-65.1%)
Mutual labels: time, clock
clocklet
An opinionated clock-style vanilla-js timepicker.
Stars: ✭ 31 (-79.19%)
Mutual labels: time, clock
Klock
Multiplatform Date and time library for Kotlin
Stars: ✭ 569 (+281.88%)
Mutual labels: time, clock
Portable Snippets
Collection of miscellaneous portable C snippets.
Stars: ✭ 397 (+166.44%)
Mutual labels: time, clock
vue-analog-clock-range
Vue Analog Clock Range Component
Stars: ✭ 53 (-64.43%)
Mutual labels: time, clock
telltime
iOS application to tell the time in the British way 🇬🇧⏰
Stars: ✭ 49 (-67.11%)
Mutual labels: time, clock
Tzupdate
Set the system timezone based on IP geolocation
Stars: ✭ 130 (-12.75%)
Mutual labels: time, clock
React-Clock
An analog clock for your React app.
tl;dr
- Install by executing
npm install react-clock
oryarn add react-clock
. - Import by adding
import Clock from 'react-clock'
. - Use by adding
<Clock />
.
Demo
A minimal demo page can be found in sample
directory.
Online demo is also available!
Installation
Add React-Clock to your project by executing npm install react-clock
or yarn add react-clock
.
Usage
Here's an example of basic usage:
import React, { useEffect, useState } from 'react';
import Clock from 'react-clock';
function MyApp() {
const [value, setValue] = useState(new Date());
useEffect(() => {
const interval = setInterval(
() => setValue(new Date()),
1000
);
return () => {
clearInterval(interval);
}
}, []);
return (
<div>
<p>Current time:</p>
<Clock value={value} />
</div>
)
}
Custom styling
If you want to use default React-Clock styling to build upon it, you can import React-Clock's styles by using:
import 'react-clock/dist/Clock.css';
User guide
Clock
Displays a complete clock.
Props
Prop name | Description | Default value | Example values |
---|---|---|---|
className | Class name(s) that will be added along with "react-clock" to the main React-Clock <time> element. |
n/a |
|
hourHandLength | Hour hand length, in %. | 50 |
80 |
hourHandOppositeLength | The length of the part of an hour hand on the opposite side the hand is pointing to, in %. | 10 |
20 |
hourHandWidth | Hour hand width, in pixels. | 4 |
3 |
hourMarksLength | Hour marks length, in %. | 10 |
8 |
hourMarksWidth | Hour marks width, in pixels. | 3 |
2 |
minuteHandLength | Minute hand length, in %. | 70 |
80 |
minuteHandOppositeLength | The length of the part of a minute hand on the opposite side the hand is pointing to, in %. | 10 |
20 |
minuteHandWidth | Minute hand width, in pixels. | 2 |
3 |
minuteMarksLength | Minute marks length, in %. | 6 |
8 |
minuteMarksWidth | Minute marks width, in pixels. | 1 |
2 |
renderHourMarks | Whether hour marks shall be rendered. | true |
false |
renderMinuteHand | Whether minute hand shall be rendered. | true |
false |
renderMinuteMarks | Whether minute marks shall be rendered. | true |
false |
renderNumbers | Whether numbers shall be rendered. | false |
true |
renderSecondHand | Whether second hand shall be rendered. | true |
false |
secondHandLength | Second hand length, in %. | 90 |
80 |
secondHandOppositeLength | The length of the part of a second hand on the opposite side the hand is pointing to, in %. | 10 |
20 |
secondHandWidth | Second hand width, in pixels. | 1 |
2 |
size | Clock size, in pixels. | 150 |
250 |
value | Clock value. Must be provided. | n/a | Date: new Date()
|
License
The MIT License.
Author
Wojciech Maj [email protected] https://wojtekmaj.pl |
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].