jbmui

Clock

  • UI
  • adjustable

A deterministic analog clock and time label. Supply time explicitly for web or video.

08:30

Install

npx shadcn@latest add @jbm/clock

Needs the @jbm entry in components.json; see Install once.

Also installs @jbm/tokens.

Docs

Usage

Half past eight
import { Clock } from "@/jbm/ui/clock"<Clock hours={8} minutes={30} size={64} />// Explicit time keeps rendering deterministic. No autoplay.
Drive it from minutes of the day
import { Clock } from "@/jbm/ui/clock"const minutes = 510 // e.g. from a slider or a video frame<Clock hours={0} minutes={minutes} size={96} label="Mañana" />

Props

Stage px
Declared at the documented defaults
Landscape
auto by 64
Vertical
auto by 64
Basis

Inline-flex row: a size × size face (64 by default), a 16px gap, and the label in 22px mono. Height equals size while it exceeds the text line; width follows the label. The row wraps when its container is narrower, putting the label below the face.

Analog face (dim ring, four quarter ticks, ink hour hand, vermilion minute hand) beside a mono HH:MM label. No timers: the time is (hours × 60 + minutes) wrapped to 24 hours, the hour hand moves continuously with the minutes, and the face is aria-hidden so the label carries the time. Throws RangeError for non-finite values or size ≤ 0.

PropTypeDefaultDescription
hoursnumberrequiredHours on a 24-hour day; fractions and values outside 0–23 wrap.
minutesnumber0Minutes added to hours; may exceed 59 (e.g. hours 0, minutes 510 is 08:30) and wraps across days.
sizenumber64Width and height of the clock face in stage pixels.
labelstringnoneText shown instead of the zero-padded 24-hour HH:MM derived from the time.

Also accepts React.HTMLAttributes<HTMLDivElement>.

QA checks

  • Sweep the time control from 00:00 to 23:59: the minute hand completes each hour, the hour hand advances smoothly, and the label matches.
  • Check 12:00 and 00:00 both point straight up and 06:00 straight down.
  • At a narrow width the label wraps below the face without clipping.