Skip to content

React Package

The React package provides React components for rendering clocks in React applications.

Installation

bash
# npm
npm install @clock-ui/react

# yarn
yarn add @clock-ui/react

# pnpm
pnpm add @clock-ui/react

# bun
bun add @clock-ui/react

Usage

BaseClock

Display a static clock at a specific time.

tsx
import { BaseClock } from "@clock-ui/react";
import "@clock-ui/react/base.css";

function App() {
  return <BaseClock hours={10} minutes={30} seconds={45} />;
}

LiveClock

Display a live clock that updates in real-time.

tsx
import { LiveClock } from "@clock-ui/react";
import "@clock-ui/react/base.css";

function App() {
  return <LiveClock smoothSweep={true} timezone="America/New_York" />;
}

Props

Shared

Both components accept these:

PropTypeDefaultDescription
useRomanbooleanfalseRoman numerals instead of Arabic. These are oriented radially, pointing outward from the centre, so the lower numerals read upside down. That is deliberate — it is how roman dials have always been set — and it is why Arabic numerals stay upright while these do not.
cardinalOnlybooleanfalseShow only 12, 3, 6, and 9.
hideNumbersbooleanfalseHide all numerals.
hideTicksbooleanfalseHide all tick marks.
hideMajorTicksbooleanfalseHide the five-minute ticks.
hideMinorTicksbooleanfalseHide the single-minute ticks.
hideSecondsbooleanfalseHide the second hand.
noBorderbooleanfalseDrop the outer frame.
dualTonebooleantrueTwo-tone hands for contrast against the face.

BaseClock

PropTypeDefaultDescription
hoursnumberRequired. 0–23.
minutesnumberRequired. 0–59.
secondsnumber00–59.
millisecondsnumber00–999. Drives sub-second hand position.
childrenReactNodeRendered in the face's info window, e.g. a date.

LiveClock

Takes the shared props plus:

PropTypeDefaultDescription
smoothSweepbooleanfalseContinuous sweep instead of ticking. Ignored under prefers-reduced-motion.
timezonestringIANA name, e.g. "Asia/Tokyo". Defaults to local time. Invalid names fall back to local.
hideDatebooleanfalseHide the date window.
tickDurationnumber600How long the second hand takes to swing to each new mark, in milliseconds. 0 snaps with no swing. Ignored in sweep mode.

LiveClock reads the clock itself, so it takes no hours/minutes.

Types

Prop types are exported if you need to wrap the components:

ts
import type {
  CommonClockProps,
  BaseClockProps,
  LiveClockProps,
} from "@clock-ui/react";

Released under the MIT License.