Skip to content

Timer

Measure elapsed or remaining time with start, pause, and reset actions.

Usage

Stopwatch

Start, pause, resume, and reset elapsed time with controls that reflect the current state.

Elapsed timeSession timer
Ready
00:00

Countdown

Set a duration, track remaining time, and receive completion feedback.

Focus sessionDuration 00:10
Ready
Session length
00:10
Session progress0%

Target

Set an elapsed-time goal and track progress until completion.

Target timerGoal 00:15
Ready
Target time
00:00
Target progress0%

API

Vue package: @sectile/vue/timer

Components
  • TimerRoot
  • TimerArea
  • TimerSeparator
  • TimerControl
  • TimerItem
  • TimerActionTrigger

Props

TimerRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

autoStart

Whether the timer starts immediately after mounting.

countdown

Whether the timer counts down instead of measuring elapsed time.

intervalMs

Delay in milliseconds between automatic updates.

startMs

Initial elapsed time in milliseconds.

targetMs

Elapsed-time target in milliseconds.

TimerPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

TimerSlotProps

completed

Whether the timer reached its target.

parts

Formatted segments of the current value.

pause

Pauses timer updates.

progress

Completion progress from 0 to 1.

reset

Restores the initial value and interaction state.

restart

Restarts timing from the configured initial value.

resume

Resumes a paused timer.

running

Whether the timer is currently running.

start

Starts timer updates.

valueMs

Current timer value in milliseconds.

Events

TimerRoot

complete

Emitted when every required segment is filled.

tick

Emitted when a timer interval produces a new value.

Other types

TimerTickHandler

ts
type TimerTickHandler = (valueMs: number) => void

TimerCompleteHandler

ts
type TimerCompleteHandler = (valueMs: number) => void

Parts

Shared scope: [data-scope="timer"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
area[data-part="area"]Provides the two-dimensional interaction surface.
item[data-part="item"]Represents one selectable or actionable item.
separator[data-part="separator"]Separates related groups without becoming an action.
control[data-part="control"]Groups the primary interactive controls.
action-trigger[data-part="action-trigger"]Invokes a timer action.

Keyboard interaction

KeyBehavior
TabMove between the component's native action controls.
Enter / SpaceInvoke the focused action.

Accessibility

Formatted time parts are grouped as one value while start, pause, reset, and restart remain named actions.

Released under the MIT License.