Counts down to a moment — a launch, a registration opening, a sale ending. Segmented boxes or compact inline text, the units you choose, localized unit names, and something else to show once the time is up. Server-safe: it renders dashes until the clock starts on the client.
Registration opens in
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { Countdown } from "@vamos-ui/react";
<Countdown to="2027-03-01T09:00:00+03:00" label="Registration opens" highlightLast />
<Countdown variant="inline" units={["hours", "minutes", "seconds"]} to={sale.endsAt} completed="Sale ended" onComplete={refresh} />role="timer" is not a live region and its sentence changes once a minute (every second only in the last minute), so the ticking never floods a screen reader. The digits are aria-hidden.
Announce the end yourself (or via completed, which is a status region) if people need to hear it.
Examples
Inline, with completed content
variant="inline" for banners and buttons; completed replaces the clock and onComplete fires once.
Units and a fixed now
The largest unit absorbs the rest (hours only → 52 h). A fixed now keeps screenshots and tests stable.
API
Countdown
| Prop | Type | Default |
|---|---|---|
toTarget moment. | string | number | Date | — |
nowFixed epoch ms for static screens and tests. Omit to tick live (every second, or every minute without a seconds unit). | number | — |
unitsUnits to show; the largest absorbs the overflow. | ("days" | "hours" | "minutes" | "seconds")[] | all four |
variantOne box per unit with a caption, or compact text ("3d 04h 12m"). | "segments" | "inline" | "segments" |
unitDisplayCaption style under each segment, from Intl ("days", "gün"). | "long" | "short" | "narrow" | "long" |
highlightLastAccent fill on the last segment. | boolean | — |
labelWhat is counted down to; prefixes the accessible sentence. | string | — |
completedShown (as role="status") once the target is reached. Default: the clock at zero. | ReactNode | — |
onCompleteFires once when the target is reached, also when it is already past on mount. | () => void | — |
labelsDictionary namespace "countdown": remaining ("{time} left"), until ("Until {date}"), completed. | Partial<CountdownLabels> | — |
countdownParts(to, now, units?)
| Prop | Type | Default |
|---|---|---|
returnsPure split for custom layouts. | { values, total (s), done } | — |