docs/components/timer
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Countdown or stopwatch with controls.
PreviewCode
00
Days
:
00
Hours
:
00
Minutes
:
00
Seconds
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/timer
Timer
├── TimerArea
│ ├── TimerItemGroup
│ │ ├── TimerItem
│ │ └── TimerItemLabel
│ ├── TimerSeparator
└── TimerControl
├── TimerActionTrigger
├── TimerStart
├── TimerPause
├── TimerResume
├── TimerReset
├── TimerRestart
└── TimerPlay
import {
Timer,
TimerArea,
TimerItem,
TimerItemGroup,
TimerItemLabel,
TimerSeparator,
TimerControl,
TimerActionTrigger,
TimerStart,
TimerPause,
TimerResume,
TimerReset,
TimerRestart,
TimerPlay,
} from "@/components/ui/timer";
<Timer targetMs={3600000} startMs={2400000}>
<TimerArea>
<TimerItemGroup>
<TimerItem type="hours" />
<TimerItemLabel>Hours</TimerItemLabel>
</TimerItemGroup>
<TimerSeparator />
<TimerItemGroup>
<TimerItem type="minutes" />
<TimerItemLabel>Minutes</TimerItemLabel>
</TimerItemGroup>
<TimerSeparator />
<TimerItemGroup>
<TimerItem type="seconds" />
<TimerItemLabel>Seconds</TimerItemLabel>
</TimerItemGroup>
</TimerArea>
<TimerControl>
<TimerPlay>Go</TimerPlay>
<TimerPause>Pause</TimerPause>
<TimerReset>Reset</TimerReset>
</TimerControl>
</Timer>
Handle onTick and onComplete to react to timer progress and completion.
PreviewCode
Ticks: 0
00
Minutes
:
00
Seconds
Use the orientation prop on TimerItemGroup to change the orientation of the timer.
PreviewCode
05
minutes
:
00
seconds
PreviewCode
05
minutes
:
00
seconds
Create a countdown by setting countdown to true and startMs to the initial duration.
PreviewCode
05
minutes
:
00
seconds
Use remainingMsUntilDate to derive startMs from a calendar date.
PreviewCode
Until Jul 9, 2026
06
days
:
23
hours
:
59
minutes
:
59
seconds
Use the interval prop to control update frequency.
PreviewCode
00
seconds
:
000
ms
Alternate between work and break sessions using onComplete.
PreviewCode
🍅
25
:
00
Focus
Trigger Behavior
Triggers hide when their action is not available. To keep a control in the layout, pass hidden={false}.
Pass children to TimerSeparator to override the default colon (:).
PreviewCode
05
//
00
Root component. Runs a stopwatch or countdown and provides timer state to child parts.
| Prop | Type | Default |
|---|---|---|
targetMs | number | 0 |
startMs | number | 0 |
countdown | boolean | false |
interval | number | 1000 |
autoStart | boolean | false |
onTick | (details: TickDetails) => void | - |
onComplete | () => void | - |
Live region that exposes the formatted time to assistive tech and lays out digit groups.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Groups a TimerItem with its TimerItemLabel and sets stack direction via orientation.
| Prop | Type | Default |
|---|---|---|
orientation | `"horizontal" | "vertical"` |
className | string | - |
asChild | boolean | false |
Caption for the adjacent TimerItem (for example, “minutes”).
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Renders one time field from the current timer value.
| Prop | Type | Default |
|---|---|---|
type | `"days" | "hours" |
asChild | boolean | false |
Visual delimiter between item groups (defaults to : when children are omitted).
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Toolbar row for timer action controls.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Button that dispatches a timer action.
| Prop | Type | Default |
|---|---|---|
action | `"start" | "pause" |
hidden | boolean | - |
asChild | boolean | false |
Starts the timer. Wraps TimerActionTrigger with action="start".
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
Pauses a running timer. Wraps TimerActionTrigger with action="pause".
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
Resumes from paused. Wraps TimerActionTrigger with action="resume".
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
Resets the timer to its initial startMs / idle state.
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
Restarts the timer. Wraps TimerActionTrigger with action="restart".
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
Shorthand for a single "go" control: renders TimerResume when the timer is paused, otherwise TimerStart.
| Prop | Type | Default |
|---|---|---|
hidden | boolean | - |
className | string | - |
asChild | boolean | false |
remainingMsUntilDate#| Parameter | Type |
|---|---|
date | Date |
Returns a number of milliseconds until date, or 0 if date is in the past.
For a complete list of props, see the Ark UI documentation.
[
Previous page
Textarea ](/docs/components/textarea)[
Next page
Toast ](/docs/components/toast)
On This Page
InstallationAnatomyUsageControlledOrientationVerticalHorizontalExamplesCountdownDate-basedIntervalPomodoroCustom separatorAPI ReferenceTimerTimerAreaTimerItemGroupTimerItemLabelTimerItemTimerSeparatorTimerControlTimerActionTriggerTimerStartTimerPauseTimerResumeTimerResetTimerRestartTimerPlayremainingMsUntilDate