Countdown Timer
A flexible progress-aware countdown (or count-up) timer with four display variants, five sizes, configurable color thresholds, pause/resume/reset controls, and an imperative ref API for external control.
Basic Circular Timer
A 30-second circular countdown. Progress ring shrinks as time runs out. Pause and reset via the controls below.
import { CountdownTimer } from 'fluxo-ui';
<CountdownTimer
duration={30}
variant="circular"
size="md"
onComplete={() => console.log('Done!')}
/>Shape Variants
Three SVG border-progress shapes: circular ring, rounded square, and equilateral triangle.
Other Variants
Linear bar, segmented blocks, and large numeric digit display.
// Circular — ring arc progress
<CountdownTimer duration={60} variant="circular" />
// Rounded Square — rounded rectangle border progress
<CountdownTimer duration={60} variant="rounded-square" />
// Triangle — equilateral triangle border progress
<CountdownTimer duration={60} variant="triangle" />
// Linear — horizontal bar progress
<CountdownTimer duration={60} variant="linear" />
// Segmented — equal blocks that disappear one by one
<CountdownTimer duration={60} variant="segmented" segmentCount={20} />
// Numeric — styled digit display
<CountdownTimer duration={3723} variant="numeric" />Sizes
Five sizes from xs to xl — applies to all variants.
<CountdownTimer duration={60} variant="circular" size="xs" />
<CountdownTimer duration={60} variant="circular" size="sm" />
<CountdownTimer duration={60} variant="circular" size="md" />
<CountdownTimer duration={60} variant="circular" size="lg" />
<CountdownTimer duration={60} variant="circular" size="xl" />Color Thresholds
Watch the auto-shift timer below — it starts primary blue, turns warning amber at ≤66% remaining, then danger red at ≤33%. Set repeat so you can observe the full cycle.
// Auto color-shift: primary → warning → danger as time runs out
// 'at' means "when remaining % is AT OR BELOW this value"
<CountdownTimer
duration={20}
variant="circular"
colorThresholds={[
{ at: 66, color: 'warning' }, // ≤66% left → warning amber
{ at: 33, color: 'danger' }, // ≤33% left → danger red
]}
repeat
/>
// Static semantic colors
<CountdownTimer duration={20} variant="circular" color="success" />
<CountdownTimer duration={20} variant="circular" color="warning" />
<CountdownTimer duration={20} variant="circular" color="danger" />
// Custom hex color
<CountdownTimer duration={20} variant="circular" color="#8b5cf6" />Count-Up Mode
Instead of counting down, elapsed time fills up the progress from 0 to the target duration.
// Count up from 0 → duration (elapsed timer)
<CountdownTimer
duration={60}
variant="circular"
countUp={true}
onComplete={() => alert('60 seconds elapsed!')}
/>Repeat & Auto-Start
Use repeat to loop infinitely on completion. Use autoStart={false} to let the user start manually.
// Repeat: automatically restarts when completed
<CountdownTimer duration={15} repeat={true} />
// Manual start: does not start until you press play
<CountdownTimer duration={30} autoStart={false} />Pause on Hover
Hover over the timer to pause it automatically — useful in interactive UIs where the user might need a moment.
// Pauses automatically while the user hovers over the timer
<CountdownTimer
duration={60}
variant="circular"
pauseOnHover={true}
/>Disabled State
Disable the timer entirely and show a custom badge message. All interaction is blocked.
// Disabled with default "Off" label
<CountdownTimer duration={30} disabled />
// Disabled with custom message
<CountdownTimer duration={30} disabled disabledMessage="Unavailable" />Long Durations
When duration exceeds 60s the display auto-promotes to minutes, hours, or days. Pass seconds only.
// 2 hours = 7200 seconds → displays "02:00 hrs"
<CountdownTimer duration={7200} variant="circular" />
// 1.5 days = 129600 seconds → displays days + hours
<CountdownTimer duration={129600} variant="numeric" />
// 90 minutes = 5400 seconds → displays "01:30 min"
<CountdownTimer duration={5400} variant="linear" />Imperative Control via Ref
Expose timer controls to parent components using a forwarded ref. Hide the built-in controls and drive the timer externally.
import { useRef } from 'react';
import { CountdownTimer } from 'fluxo-ui';
import type { CountdownTimerHandle } from 'fluxo-ui';
const timerRef = useRef<CountdownTimerHandle>(null);
<CountdownTimer ref={timerRef} duration={30} autoStart={false} showControls={false} />
<button onClick={() => timerRef.current?.start()}>Start</button>
<button onClick={() => timerRef.current?.pause()}>Pause</button>
<button onClick={() => timerRef.current?.resume()}>Resume</button>
<button onClick={() => timerRef.current?.reset()}>Reset</button>Import
import { CountdownTimer } from 'fluxo-ui';
import type { CountdownTimerProps, CountdownTimerHandle } from 'fluxo-ui';Props
durationreqnumberTotal duration in seconds.
durationreqnumberTotal duration in seconds.
variant'circular' | 'rounded-square' | 'triangle' | 'linear' | 'segmented' | 'numeric'"'circular'"Visual display style.
variant'circular' | 'rounded-square' | 'triangle' | 'linear' | 'segmented' | 'numeric'"'circular'"Visual display style.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"'md'"Size of the timer control.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"'md'"Size of the timer control.
autoStartbooleantrueStart the timer immediately on mount.
autoStartbooleantrueStart the timer immediately on mount.
repeatbooleanfalseAutomatically restart when completed.
repeatbooleanfalseAutomatically restart when completed.
countUpbooleanfalseCount up from 0 to duration instead of counting down.
countUpbooleanfalseCount up from 0 to duration instead of counting down.
color'primary' | 'success' | 'warning' | 'danger' | string"'primary'"Static color for the progress indicator. Accepts semantic names or any CSS color.
color'primary' | 'success' | 'warning' | 'danger' | string"'primary'"Static color for the progress indicator. Accepts semantic names or any CSS color.
colorThresholdsColorThreshold[]Array of { at: number (%), color } breakpoints for auto color-shifting.
colorThresholdsColorThreshold[]Array of { at: number (%), color } breakpoints for auto color-shifting.
segmentCountnumber20Number of segments for the segmented variant.
segmentCountnumber20Number of segments for the segmented variant.
showControlsbooleantrueShow the built-in pause and reset buttons.
showControlsbooleantrueShow the built-in pause and reset buttons.
pauseOnHoverbooleanfalseAutomatically pause when the user hovers over the timer.
pauseOnHoverbooleanfalseAutomatically pause when the user hovers over the timer.
disabledbooleanfalseDisable the timer — no interaction, shows disabled badge.
disabledbooleanfalseDisable the timer — no interaction, shows disabled badge.
disabledMessagestring"'Off'"Badge text shown when disabled.
disabledMessagestring"'Off'"Badge text shown when disabled.
pulseWhenRunningbooleanfalseApply a subtle pulse animation to the time display while running.
pulseWhenRunningbooleanfalseApply a subtle pulse animation to the time display while running.
announceIntervalnumberAnnounce the remaining time via aria-live region every N seconds (e.g. 60 for once-per-minute).
announceIntervalnumberAnnounce the remaining time via aria-live region every N seconds (e.g. 60 for once-per-minute).
announceFinalSecondsnumberWhen remaining seconds drops to or below this value, announce every second via aria-live (e.g. 10 for the final ten-second countdown).
announceFinalSecondsnumberWhen remaining seconds drops to or below this value, announce every second via aria-live (e.g. 10 for the final ten-second countdown).
announceOnCompletebooleanfalseAnnounce 'Timer complete' via aria-live region when the timer reaches zero.
announceOnCompletebooleanfalseAnnounce 'Timer complete' via aria-live region when the timer reaches zero.
announcePoliteness'polite' | 'assertive'"'polite'"aria-live politeness for the announcement region.
announcePoliteness'polite' | 'assertive'"'polite'"aria-live politeness for the announcement region.
criticalThresholdnumberFire onCriticalThreshold once when remaining seconds first drops to or below this value.
criticalThresholdnumberFire onCriticalThreshold once when remaining seconds first drops to or below this value.
onCriticalThreshold(remaining: number) => voidCalled the first time remaining time crosses criticalThreshold (resets on reset/restart).
onCriticalThreshold(remaining: number) => voidCalled the first time remaining time crosses criticalThreshold (resets on reset/restart).
classNamestringAdditional CSS class name.
classNamestringAdditional CSS class name.
styleReact.CSSPropertiesInline style override.
styleReact.CSSPropertiesInline style override.
onComplete() => voidCalled when the timer reaches zero (or duration in count-up mode).
onComplete() => voidCalled when the timer reaches zero (or duration in count-up mode).
onTick(remaining: number, elapsed: number) => voidCalled every second with remaining and elapsed values.
onTick(remaining: number, elapsed: number) => voidCalled every second with remaining and elapsed values.
onPause(remaining: number) => voidCalled when the timer is paused.
onPause(remaining: number) => voidCalled when the timer is paused.
onResume(remaining: number) => voidCalled when the timer resumes.
onResume(remaining: number) => voidCalled when the timer resumes.
onReset() => voidCalled when the timer is reset.
onReset() => voidCalled when the timer is reset.
Ref Handle (CountdownTimerHandle)
start()functionStart the timer if not already running.
start()functionStart the timer if not already running.
pause()functionPause the timer.
pause()functionPause the timer.
resume()functionResume a paused timer.
resume()functionResume a paused timer.
reset()functionReset to initial value. Restarts automatically if autoStart is true.
reset()functionReset to initial value. Restarts automatically if autoStart is true.
6 Variants
Circular ring, rounded square, triangle, linear bar, segmented blocks, and pure numeric digit display.
5 Sizes
From compact xs to large xl — all variants scale uniformly.
Color Thresholds
Define percentage breakpoints to automatically shift color as urgency increases.
Count-Up / Count-Down
Switch between elapsed timer and deadline countdown with a single prop.
Repeat & Auto-Start
Loop the timer infinitely and control whether it starts on mount or on demand.
Pause on Hover
Automatically pauses the timer when the user mouses over it.
Imperative Ref
Control start, pause, resume, and reset from parent code via a forwarded ref handle.
Disabled State
Disable the timer with a customizable badge message (defaults to "Off").
Smart Time Format
Automatically promotes display from seconds → minutes → hours → days based on duration.