Homelogologo
Sponsor

Timer

A component used to manage and display time-based counts or countdowns.

Usage

The Timer component consists of a root container and several subcomponents to manage and display time units and controls.

import { Timer } from "@elemnts-ui/react"; <Timer.Root startMs={60 * 60 * 1000}> <Timer.Area> <Timer.ItemGroup> <Timer.Item type="hours" /> <Timer.ItemLabel>Hours</Timer.ItemLabel> </Timer.ItemGroup> <Timer.Separator>:</Timer.Separator> <Timer.ItemGroup> <Timer.Item type="minutes" /> <Timer.ItemLabel>Minutes</Timer.ItemLabel> </Timer.ItemGroup> <Timer.Separator>:</Timer.Separator> <Timer.ItemGroup> <Timer.Item type="seconds" /> <Timer.ItemLabel>Seconds</Timer.ItemLabel> </Timer.ItemGroup> </Timer.Area> <Timer.Control> <Timer.ActionTrigger action="start">Start</Timer.ActionTrigger> <Timer.ActionTrigger action="pause">Pause</Timer.ActionTrigger> </Timer.Control> </Timer.Root>;

Countdown

Set the countdown prop on the Root component to decrement the timer.

API Reference

TimerRoot

The root component that manages timer state.

PropTypeDefault
asChildbooleanfalse
autoStartboolean-
countdownboolean-
idsPartial<{ root: string; area: string }>-
intervalnumber1000
onComplete() => void-
onTick(details: TickDetails) => void-
startMsnumber-
targetMsnumber-
translationsIntlTranslations-

TimerRootProvider

Provides timer state created with useTimer to its descendants.

PropTypeDefault
valueUseTimerReturnrequired
asChildbooleanfalse

TimerArea

Wraps the displayed timer items.

PropTypeDefault
asChildbooleanfalse

TimerItem

Displays a formatted unit of time.

PropTypeDefault
typekeyof Time<number>required
asChildbooleanfalse

TimerItemGroup

Groups a timer item with its label.

PropTypeDefault
asChildbooleanfalse

TimerItemLabel

Labels a timer item.

PropTypeDefault
asChildbooleanfalse

TimerSeparator

Separates timer items.

PropTypeDefault
asChildbooleanfalse

TimerControl

Wraps timer action controls.

PropTypeDefault
asChildbooleanfalse

TimerActionTrigger

Triggers an action on the timer.

PropTypeDefault
actionTimerActionrequired
asChildbooleanfalse