Components · Feedback
Countdown
Time left to a deadline, as a chip or inline text. Stays right after the tab was in the background.
import { Countdown } from '@nexub/react';Playground
Props
<Countdown to={deadline} onExpire={…} />Examples
Hold timer
Resend button with useCountdown
States
- Held for you0:00
default - Held for you0:00
size="sm" - Held for you0:00
size="md" - Held for you0:00
size="lg" - Held for you0:00
variant="inline" - Held for you0:00
variant="chip" - Held for you0:00
tone="neutral" - Held for you0:00
tone="warning" - Held for you0:00
tone="danger" - Held for you0:00
tone="auto"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| torequired | number | Date | — | The deadline: a Date or milliseconds since the epoch. Not a duration. |
| format | 'auto' | 'm:ss' | 'h:mm:ss' | 'auto' | auto shows hours only from one hour up. |
| variant | 'inline' | 'chip' | 'chip' | A small badge, or plain text in the surrounding font. |
| size | 'sm' | 'md' | 'lg' | 'md' | Size of the chip. |
| tone | 'neutral' | 'warning' | 'danger' | 'auto' | 'auto' | auto turns warning under warnAt and danger under dangerAt. |
| warnAt | number | 60 | Thresholds for tone="auto", in seconds. |
| dangerAt | number | 10 | Thresholds for tone="auto", in seconds. |
| onExpire | (() => void) | — | Called once when the deadline is reached. |
| now | (() => number) | — | The clock. Inject one for tests and static previews. |
Accessibility
Notes
The digits are a `timer` that is not read on every tick. A separate polite region speaks each whole minute, then at 30, 10 and 5 seconds, and when time is up.
The server and the first paint show a placeholder of the same width; the time appears after mount, so there is no hydration mismatch.
`useCountdown(to, { now, onExpire })` returns `{ remainingMs, seconds, expired, ready }` for custom displays.
On iOS & Android: Countdown
import { Countdown } from '@nexub/react-native';
<Countdown to={expiresAt} onExpire={resend} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| In the background | Reads the clock again when the tab is visible. | Reads the clock again when the app returns to the foreground. |
| Announcements | A polite live region. | VoiceOver and TalkBack announcements at the same moments: each minute, 30, 10 and 5 seconds, and the end. |
| Sizes | sm, md and lg chips. | sm and md chips. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
Countdown props
| Prop | Type | Default | Description |
|---|---|---|---|
| torequired | number | Date | — | The deadline: a Date or ms since the epoch. |
| format | 'm:ss' | 'h:mm:ss' | 'auto' | 'auto' | auto shows hours only from one hour up. |
| size | 'sm' | 'md' | 'md' | Chip size. |
| variant | 'chip' | 'inline' | 'chip' | chip is a small badge; inline is plain text. |
| tone | 'auto' | CountdownTone | 'auto' | auto: neutral, warning under warnAt, danger under dangerAt. |
| warnAt | number | 60 | Seconds. |
| dangerAt | number | 10 | Seconds. |
| style | StyleProp<ViewStyle & TextStyle> | — | — |
| now | () => number | — | The clock, in ms. Defaults to Date.now; inject one for tests and static previews. |
| onExpire | () => void | — | Called once when the deadline is reached (also when it has already passed on mount). |