Skip to content
nexubDesign System
v11.9.0

Components · Feedback

Countdown

AlphaAdded v10.8.0

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';
View as Markdown

Playground

Props

variant
tone
size
format
Held for you
TSX
<Countdown to={deadline} onExpire={…} />

Examples

Hold timer

Held for you

Resend button with useCountdown

States

  • Held for you
    default
  • Held for you
    size="sm"
  • Held for you
    size="md"
  • Held for you
    size="lg"
  • Held for you
    variant="inline"
  • Held for you
    variant="chip"
  • Held for you
    tone="neutral"
  • Held for you
    tone="warning"
  • Held for you
    tone="danger"
  • Held for you
    tone="auto"

Props

Props
PropTypeDefaultDescription
torequirednumber | 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.
warnAtnumber60Thresholds for tone="auto", in seconds.
dangerAtnumber10Thresholds 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.