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 fromdurationseconds."stopwatch"counts up with no end."interval"walks throughphases([{ label: "Work", seconds: 25 }, { label: "Rest", seconds: 5 }])roundstimes 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 toh:mm:ss. - Buttons: Start, Pause (then Resume), Reset.
:controls="false"hides them.v-model:runningreads or sets it, the component exposesstart(),pause(),reset()andtoggle(), andautostartbegins at once. Changing the plan resets the clock. finishfires 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
| Name | Type | Default | Description |
|---|---|---|---|
mode | "countdown" | "stopwatch" | "interval" | "countdown" | `countdown` from `duration`, `stopwatch` up from 0, `interval` through `phases` |
duration | number | 60 | seconds, for a countdown |
phases | BlessTimerPhase[] | — | for `interval`: e.g. `[{ label: "Work", seconds: 25 }, { label: "Rest", seconds: 5 }]` |
rounds | number | 1 | how many times the phases repeat |
autostart | boolean | — | |
controls | boolean | true | show Start / Pause / Reset |
label | string | "Timer" | |
labels | Partial<{ 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 |
running | boolean | false |
Events
| Name | Payload | Description |
|---|---|---|
finish | [] | |
update:running | [value: boolean] | |
phase | [phase: BlessTimerPhase, index: number, round: number] |
Exposed
| Name | Type | Description |
|---|---|---|
start | () => void | |
pause | () => void | |
reset | () => void | |
toggle | () => boolean |