Skip to content

Timer

@astryxdesign/core v0.7.1 · Timer

Usage ​

Timer writes a running duration into a <time> element. startTime is unix milliseconds. Omit it and the count starts when this timer mounts. The text and dateTime are written on the element. The component does not re-render on every tick, and it does not use aria-live.

format="elapsed" is the default. Under a minute it reads Ns. Under an hour it reads Nm NNs. At an hour and beyond it reads Nh NNm and drops seconds, both in the text and in dateTime (PT{minutes * 60}S). format="clock" stays on seconds: m:ss, or h:mm:ss past an hour, with dateTime="PT{seconds}S".

The clock updates once a second until the elapsed format reaches an hour, then once a minute. If startTime is still in the future, the first change waits until one second after that start.

Typography matches Timestamp. type defaults to supporting, color to secondary. type="inherit" does not wrap the time in Text, so it takes the surrounding font. color="disabled" uses the disabled text color. size and weight override the type scale the same way they do on Text.

vue
<script setup lang="ts">
import { Text } from '@astryx-vue/core/Text'
import { Timer } from '@astryx-vue/core/Timer'
</script>

<template>
  <Text type="body" color="primary">
    Processing for <Timer type="inherit" color="inherit" />
  </Text>
</template>

Anatomy

ElementDescription
Elapsed timeSemantic time element containing a standardized elapsed duration.

Best practices ​

GuidancePractices
DoUse elapsed next to a status word, and clock when the reader is watching seconds.
DoPass the same startTime when two timers must agree.
DoUse type="inherit" inside a sentence so the duration matches the line.
Don'tAnnounce every tick. The time element updates in place and stays quiet.
Don'tExpect second precision from elapsed after one hour. That format switches to minutes on purpose.

Examples ​

Timer — Formats

Elapsed
Clock

Elapsed compact units and stopwatch clock notation shown from the same start time.

Timer — Inline

Processing for

A Timer composed into status copy while inheriting the surrounding typography.

Timer — Typography

Default Emphasized

Timer using its Timestamp-matched default typography and an emphasized override.