use-countdown
Counts down to a target date or from a given duration
Source
Package
Usage
use-countdown counts down from a duration in milliseconds (countStart) or to a date (targetDate).
It returns the remaining time and the same value split into days, hours, minutes and seconds.
With countStart, call start to begin the countdown. Once it reaches 0, start restarts it:
Count down to a target date
Pass targetDate to count down to a specific moment. The countdown starts automatically:
00
Days
00
Hours
00
Minutes
00
Seconds
Controls
Use start, stop and reset functions to control the countdown. start resumes a stopped countdown:
10s
Running: no
Interval and sub-second precision
interval controls how often the countdown updates, one second by default.
Use a smaller interval to display milliseconds:
5.000
onComplete and onTick
onComplete is called once when the countdown reaches 0. onTick is called on every tick with
the remaining milliseconds:
API
Definition
Exported types
UseCountdownOptions, UseCountdownReturnValue and UseCountdownFormatted types are exported from
the @mantine/hooks package, you can import them in your application: