Skip to content
Calm motion: animations on this site only fade, with no movement

Timer ​

Countdown, stopwatch and interval timer

A clock the user starts and stops: a cooking timer, a workout, a speaking slot. To pick a time use TimePicker. For progress toward a goal that is not time, Progress.

Basic
Countdown
01:30
Stopwatch
00:00
Interval: 3 rounds of work and rest
Work · round 1 of 300:25
  • mode="countdown" counts down from duration seconds. "stopwatch" counts up with no end. "interval" walks through phases ([{ label: "Work", seconds: 25 }, { label: "Rest", seconds: 5 }]) rounds times and shows which phase and round it is in.
  • Time comes from performance.now(), not from counting ticks, so a throttled background tab or a busy page does not make it drift. Past an hour the display turns to h:mm:ss.
  • Buttons: Start, Pause (then Resume), Reset. :controls="false" hides them. v-model:running reads or sets it, the component exposes start(), pause(), reset() and toggle(), and autostart begins at once. Changing the plan resets the clock.
  • finish fires once at the end of a countdown or interval. phase(phase, index, round) on every change of phase. Finishing and phase changes are announced. The ticking itself is not, so a screen reader is not read a number every second.
  • Starting a finished timer begins a fresh run.

Usage ​

ts
import { BlessTimer } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
mode"countdown" | "stopwatch" | "interval""countdown"`countdown` from `duration`, `stopwatch` up from 0, `interval` through `phases`
durationnumber60seconds, for a countdown
phasesBlessTimerPhase[]—for `interval`: e.g. `[{ label: "Work", seconds: 25 }, { label: "Rest", seconds: 5 }]`
roundsnumber1how many times the phases repeat
autostartboolean—
controlsbooleantrueshow Start / Pause / Reset
labelstring"Timer"
labelsPartial<{ start: string; resume: string; pause: string; reset: string; finished: string; round: (round: number, rounds: number) => string; }>—button text and the wording said when a phase changes or the time is up
runningbooleanfalse

Events

NamePayloadDescription
finish[]
update:running[value: boolean]
phase[phase: BlessTimerPhase, index: number, round: number]

Exposed

NameTypeDescription
start() => void
pause() => void
reset() => void
toggle() => boolean

Released under the MIT License. Character names and artwork belong to their owners.