Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useCountdown

A pausable countdown or count-up that stops at its target.

HooksState@gaudi/design-system/hooks/state/use-countdownView in StorybookSource

Composes useInterval with count state. Changing the interval restarts the timer interval; reset stops it and restores the current countStart. Counts represent ticks, not elapsed wall-clock time.

Usage

import { useCountdown } from '@gaudi/design-system/hooks';
const { count, isRunning, start, stop, reset } = useCountdown({ countStart: 30 });

Examples

Playground

Storybook

API

4 options
2 return values

Accessibility

Keep pause and reset controls available. Avoid announcing every tick; announce completion separately.

Notes

  • Timers can be throttled in background tabs. Use an application deadline for time-critical expiry.
  • Starting at or beyond the target does not run.