Skip to content
Alea0.1

Data display

Countdown and FormattedNumber

Time left until a moment, and numbers formatted for the reader: currency, percent, compact.

Ant Design: Statistic.Countdown

import { Countdown, FormattedNumber } from '@alea/ui';

Examples

Countdown and numbers

The countdown updates every second; screen readers hear it once a minute.

Launch in2 days, 4 hours, 59 minutes

Revenue

$126,560

1.8M visits · 4.3% conversion

Props

Countdown props

Time left until a moment, updating every second (Ant Statistic.Countdown). Screen readers hear it once a minute, not every second.

PropTypeDefaultDescription
labelrequiredReactNode-What it counts down to, read before the time ("Sale ends in").
torequirednumber | Date-When it ends: a Date or a timestamp in ms.
classNamestring-
onEnd(() => void)-Called once when it reaches zero.
showDaysboolean-Show days. Default true when there is more than a day left.

FormattedNumber props

A number formatted for the reader's locale: currency, percent, compact (Chakra FormatNumber, Mantine NumberFormatter).

PropTypeDefaultDescription
valuerequirednumber-
formatNumberFormatOptions-Intl.NumberFormat options: { style: 'currency', currency: 'USD' }, { notation: 'compact' }, { style: 'percent' }.
localestring-A BCP 47 locale. Default the browser's.

Accessibility

  • The countdown ticks visually every second, but screen readers hear it once a minute (a polite live region), not sixty times.

Do and don't

Do

  • Say what it counts down to in label.
  • Use FormattedNumber instead of formatting by hand: it follows the reader's locale.

Don't

  • Don't use a countdown to pressure people into buying.
Tested with axe, keyboard and screen reader roles