Countdown Timer
React Native (Expo)
A React Native minutes and seconds countdown with a draining bar that pauses, resumes and fires once when time is up.
A minutes and seconds countdown with a bar that drains underneath. Pausing holds both the digits and the bar and resuming carries on from there. When the time is up the digits turn to the done colour and onComplete fires once. The remaining time is not announced every second, only "Time is up", so a screen reader is not flooded. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add countdown-timerManual
- Copy the code from the component tab.
- Create a file at
components/ui/countdown-timer.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
seconds | number | - | How long to count down from. Changing it restarts the timer. |
running | boolean | true | Pauses the countdown when false. |
onComplete | () => void | - | Called once when the time runs out. |
label | string | "Timer" | Spoken name of the timer. |
colors | Partial<CountdownTimerColors> | - | Overrides text, track, fill and done. |
style | StyleProp<ViewStyle> | - | Style for the timer's container. |
Comments