Ark Logo
Undefined
Components
Timer

Timer

Used to record the time elapsed from zero or since a specified target time.

01

days

16

hours

00

minutes

00

seconds

Examples

Learn how to use the Timer component in your project. Let's take a look at the most basic example:

Countdown Timer

You can create a countdown timer by setting the targetMs prop to a future timestamp:

Timer Events

The Timer component provides events that you can listen to for various timer-related actions.

  • The onComplete event is triggered when the timer reaches its target time.
  • The onTick event is called on each timer update, providing details about the current timer state.

Using the Root Provider

The RootProvider component provides a context for the timer. It accepts the value of the useTimer hook. You can leverage it to access the component state and methods from outside the timer.

If you're using the RootProvider component, you don't need to use the Root component.

API Reference