Skip to content

Timer Display

Token-aware timer widget with start, pause, and stop controls. Formats elapsed time as MM:SS or H:MM:SS.

Timer States

00:00
Ready
03:03
Running
1:02:03
Paused

Import

typescript
import { DsTimerDisplay } from '@verkview/design-system'

Usage

vue
<script setup>
import { ref } from 'vue'

type TimerState = 'idle' | 'running' | 'paused'

const state = ref<TimerState>('idle')
const tracked = ref(0)
const startedAt = ref<number | null>(null)

const start = () => {
  startedAt.value = Date.now()
  state.value = 'running'
}

const pause = () => {
  if (startedAt.value) tracked.value += Date.now() - startedAt.value
  startedAt.value = null
  state.value = 'paused'
}

const stop = () => {
  if (startedAt.value) tracked.value += Date.now() - startedAt.value
  startedAt.value = null
  tracked.value = 0
  state.value = 'idle'
}
</script>

<template>
  <DsTimerDisplay
    :timer-state="state"
    :time-tracked="tracked"
    :timer-started-at="startedAt"
    @start="start"
    @pause="pause"
    @stop="stop"
  />
</template>

Props

PropTypeDefaultDescription
timerState'idle' | 'running' | 'paused'requiredCurrent state of the timer
timeTrackednumberrequiredAccumulated time in milliseconds (not including the current running segment)
timerStartedAtnumber | nullnullDate.now() value when the current running segment started — used to compute live elapsed time

Events

EventDescription
startUser pressed the play button
pauseUser pressed the pause button
stopUser pressed the stop button

States

Idle

No time recorded. Only a play button is shown.

00:00
Ready

Running

Timer is active. Shows a pause button and stop button.

01:30
Running

Paused

Timer is paused. Shows a play button (to resume) and stop button.

1:02:03
Paused

Time format

DurationFormatExample
Under 1 hourMM:SS04:37
1 hour or moreH:MM:SS1:02:15

timeTracked is in milliseconds — pass Date.now() - startedAt as the running segment offset via timerStartedAt.

Examples

Task timer in a card

vue
<script setup>
import { ref } from 'vue'

const state = ref<'idle' | 'running' | 'paused'>('idle')
const tracked = ref(0)
const startedAt = ref<number | null>(null)
</script>

<template>
  <DsCard class="flex items-center justify-between p-4">
    <div>
      <p class="font-medium">Design review</p>
      <DsBadge variant="info">In Progress</DsBadge>
    </div>

    <DsTimerDisplay
      :timer-state="state"
      :time-tracked="tracked"
      :timer-started-at="startedAt"
      @start="() => { startedAt = Date.now(); state = 'running' }"
      @pause="() => { tracked += Date.now() - startedAt!; startedAt = null; state = 'paused' }"
      @stop="() => { tracked = 0; startedAt = null; state = 'idle' }"
    />
  </DsCard>
</template>