React Native · Components
Countdown
Countdown or count-up (same API as web): sale end, "resend in 60 s", call duration.
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Campaign card
Resend code (a component instead of useCountdown)
Import
Countdown
componentCountdown or count-up (same API as web): sale end, "resend in 60 s", call duration. Variants clock, text, boxes; unit names in the device language (Intl; where Hermes lacks it, a fallback table giving the same text).
- Re-renders only when the smallest visible unit changes; pauses in the background and resumes from the real clock when brought to the front.
urgentturns it red with a pulse in the final moments. Digits have equal widths (tabular-nums); text does not shift when numbers change.- Screen reader: "timer" role, announced once when it finishes.
Examples
unitLabel
functionOnly the unit name, by language and number ("gün", "days", "day"). Uses Intl; no translation needed.
formatCountdown
functionTurns a duration into readable text: "2 days 3 hours 4 minutes". Zero units are skipped (the smallest unit is written when all are zero).
useCountdown
functionCountdown or count-up hook (same API as web): for drawing your own UI.
- Efficient: wakes up not every second but when the smallest visible unit changes (once a minute if only minutes are shown).
- Background: the timer stops when the app goes to the background and is recomputed from the real clock when it comes to the front; no drift.
Examples
CountdownVariant
typeCountdown variant (same as web).
clock: digital clock:2 days 03:04:05,12:30.text: readable text: "2 days 3 hours 4 minutes".boxes: each unit in its own box with its name below (campaigns, events).
CountdownStyles
interfaceStyles of the inner parts of Countdown (the counterpart of classNames on web).
| Name | Type | Description |
|---|---|---|
unit? | StyleProp<ViewStyle> | Unit box (boxes) or unit group. |
value? | StyleProp<TextStyle> | Number. |
label? | StyleProp<TextStyle> | Unit name. |
separator? | StyleProp<TextStyle> | Separator (:). |
CountdownProps
interfaceProps of the Countdown component.
| Name | Type | Default | Description |
|---|---|---|---|
variant? | CountdownVariant | (string & {}) | "clock" | Variant: a built-in one or a name added with appearance.variants.countdown. Defaults to UIProvider appearance.defaults.countdown.variant. |
effect? | EffectProp | Effect or effects (e.g. "shine"). In the boxes variant applied to each unit box, otherwise to the counter itself. | |
size? | "sm" | "md" | "lg" | "md" | Size. |
tone? | Tone | "neutral" | Color of the boxes in the boxes variant. |
urgent? | number | Looks "urgent" once the remaining time drops below this (ms): red with a light pulse (no pulse with reduced motion). Works when counting down. | |
labels? | "long" | "short" | "narrow" | false | "long" | Unit names: full ("long"), short ("short") or shortest. |
completed? | ReactNode | Content shown when finished (e.g. "The sale has started!"). If omitted zeros are shown. | |
placeholder? | ReactNode | For an API shared with web; on native the numbers are ready on the first render. | |
label? | string | Screen reader name (e.g. "Time left until the sale ends"). The counter is not announced every second; it is announced once when it finishes. | |
tooltip? | TooltipProp | Tooltip on long press. See TooltipProp. | |
style? | StyleProp<ViewStyle> | Container style. | |
styles? | CountdownStyles | Styles of the inner parts. | |
testID? | string | Test id. | |
to? | CountdownDate | Target moment: counts down to this moment. | |
duration? | number | Duration (ms): counts down to this long after the first render (e.g. "resend in 60 s"). | |
from? | CountdownDate | Start moment: counts up the time elapsed since this moment (e.g. call duration). | |
units? | readonly CountdownUnit[] | "auto" | "auto" | Units shown, from largest to smallest. "auto": based on the remaining time (days if there are days, otherwise hours…). |
precise? | boolean | false | Millisecond precision (updates every frame). |
paused? | boolean | Paused. | |
onComplete? | () => void | Called once when the countdown finishes. | |
onTick? | (parts: CountdownParts) => void | Called whenever the visible value changes. |
CountdownDate
typeDate: Date, an ISO string ("2026-12-31T23:59:59+03:00") or milliseconds.
CountdownUnit
typeUnits that can be shown, largest to smallest.
CountdownParts
interfaceThe remaining (or elapsed) time split into units.
| Name | Type | Description |
|---|---|---|
total | number | Total time (ms); 0 when a countdown ends. |
days | number | Days. Added to hours when days are not shown. |
hours | number | Hours. |
minutes | number | Minutes. |
seconds | number | Seconds. |
milliseconds | number | Milliseconds (0–999). |
UseCountdownOptions
interfaceOptions of useCountdown (same as web).
| Name | Type | Default | Description |
|---|---|---|---|
to? | CountdownDate | Target moment: counts down to this moment. | |
duration? | number | Duration (ms): counts down to this long after the first render (e.g. "resend in 60 s"). | |
from? | CountdownDate | Start moment: counts up the time elapsed since this moment (e.g. call duration). | |
units? | readonly CountdownUnit[] | "auto" | "auto" | Units shown, from largest to smallest. "auto": based on the remaining time (days if there are days, otherwise hours…). |
precise? | boolean | false | Millisecond precision (updates every frame). |
paused? | boolean | Paused. | |
onComplete? | () => void | Called once when the countdown finishes. | |
onTick? | (parts: CountdownParts) => void | Called whenever the visible value changes. |
UseCountdownResult
interfaceResult of useCountdown.
Extends: CountdownParts
| Name | Type | Description |
|---|---|---|
done | boolean | Whether the countdown has finished. |
running | boolean | Whether it is counting (not paused and not finished). |
ready | boolean | Whether the value is ready (always true on native; same field as web). |
units | readonly CountdownUnit[] | Units shown. |
direction | "down" | "up" | Direction: down with to/duration, up with from. |
pause | () => void | Pauses. |
resume | () => void | Resumes. |
reset | (duration?: number) => void | Starts over; in duration mode a new duration can be given. |