Loading...
Skip to main content

Countdown

Countdown renders the remaining time to a target moment as a list of time sections, updating every second until the end time is reached.

Example

<Countdown
  className="d-flex gap-3"
  endTime="2035-01-01T00:00:00"
  units={[
    {
      label: 'days',
      scale: 24
    },
    {
      label: 'hours',
      scale: 60
    },
    {
      label: 'minutes',
      scale: 60
    },
    {
      label: 'seconds',
      scale: 1000
    }
  ]}
/>

Units

units lists the sections from largest to smallest. Each scale is the amount of the next smaller unit that makes up one of the current unit, ending at milliseconds.

<Countdown
endTime="2030-01-01T00:00:00"
onEnd={function ve(){}}
units={[
{
label: 'days',
scale: 24
},
{
label: 'hours',
scale: 60
},
{
label: 'minutes',
scale: 60
},
{
label: 'seconds',
scale: 1000
}
]}
/>

itemClassName styles each section, and onEnd fires once when the countdown reaches zero.

Documentation navigation
On this page
On this page