Countdown
Deadline-based countdown with rolling digits and a single completion confetti burst.
npx @swipeui/cli add countdownWhen to use it
- Launches, live events, auctions or sales that start at a set time.
- "Starts in" timers on event and streaming screens.
- Showing a live state, such as a Watch now button, when the time arrives.
When not to use it
- Workout or cooking timers people start and pause. Build those with your own state.
- Long-range dates days away; show the date instead.
- Progress through a task. Use Progress.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add countdown- Adds
components/swipeui/ui/countdown.tsx,components/swipeui/ui/countdown-confetti.tsxand 7 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Countdown } from '@/components/swipeui/ui/countdown';
<Countdown endsAt={launchAt} label="Launch starts in" />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
CountdownProps
| Prop | Type | Default | Description |
|---|---|---|---|
format? | | | Clock, separated time units or total seconds. |
appearance? | | | Plain numbers or elevated surfaces. |
numberStyle? | | | Number typography. |
numberTextClassName? | | | Caller numeral classes. |
unitLabels? | | | Translated unit labels. |
endsAt | | — | Absolute epoch milliseconds; never a decrementing duration. |
onComplete? | | — | Invoked once for each distinct deadline, when first observed at or after zero. |
liveLabel? | | | Displayed at zero; legacy prop name retained. |
confetti? | | | One confetti burst per deadline; respects reduced motion and visibility. |
liveContent? | | — | Optional live-state content. |
label? | | | Spoken timer purpose. |
motion? | | — | Shared rolling-number feel. |
className? | | — | Root classes. |
style? | | — | Native layout escape hatch. |
testID? | | — | Root ID. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- endsAt is the deadline; label names it, such as "Starts in".
- liveLabel or liveContent replace it at zero; onComplete runs once per deadline.
Feedback lineup settings
| Prop | Does / default |
|---|---|
format | Clock, separated time units or total seconds. @default 'clock' |
appearance | Plain numbers or elevated surfaces. @default 'plain' |
numberStyle | Number typography. @default 'mono' |
numberTextClassName | Caller numeral classes. @default undefined |
unitLabels | Translated unit labels. @default hours/minutes/seconds |
endsAt | Absolute epoch milliseconds; never a decrementing duration. |
onComplete | Invoked once for each distinct deadline, when first observed at or after zero. |
liveLabel | Displayed at zero; legacy prop name retained. @default 'Complete' |
liveContent | Optional live-state content. |
label | Spoken timer purpose. @default 'Starts in' |
motion | Shared rolling-number feel. |
className | Root classes. |
style | Native layout escape hatch. |
testID | Root ID. |
Behaviour
format is clock, units or seconds; appearance is plain or elevated. numberStyle selects mono, sans or display; numberTextClassName customizes numerals. All clocks use absolute endsAt deadlines and recalculate on resume. Each specimen starts with a ten-second deadline and Restart resets it.
Completion defaults to Complete with one confetti burst per deadline. confetti={false} disables the burst; Reduce Motion keeps the static completion message. The Live demo board was removed; liveLabel and liveContent remain supported for existing callers. Restart with a new deadline to begin a fresh countdown and completion event.
Behavior and gestures
- Counts down once a second with rolling digits.
- At zero it switches to the live label or your liveContent, and onComplete runs once.
- It uses an absolute end time, so it stays correct after the app was in the background.
Accessibility
- Announced as a timer with full words, such as "Starts in 2 hours, 5 minutes, 10 seconds".
- The live state is announced once when it arrives.
- Rolling digits are hidden from screen readers to avoid chatter.
Motion
- Uses the
numberandambientmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Digits roll with the number role.
- Reduce Motion changes digits instantly.
Performance
- One tick per second; it never counts down a duration that could drift.
Notes for AI
- Pass endsAt as epoch milliseconds from your server.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.