A component that displays a countdown timer with days, hours, minutes, and seconds. The countdown can be set to a specific date or a duration in days, hours, minutes, and seconds.
See the Example by Serhii Pimenov on CodePen .
< div data-role = "countdown" ></ div >
< div data-role = "countdown" data-animate = "slide" ></ div >
< div data-role = "countdown" data-font-size = "96" ></ div >
< div data-role = "countdown" data-date = "2025/05/15" ></ div >
< div data-role = "countdown" data-days = "2" data-hours = "12" data-minutes = "30" data-seconds = "15" ></ div >
Parameter Type Default Description countdownDeferrednumber 0 Deferred start of countdown in milliseconds stopOnBlurboolean true Stop countdown when window loses focus animatestring ”none” Animation type: “none”, “slide”, “fade”, “zoom” easestring ”linear” Animation easing function durationnumber 600 Animation duration in milliseconds inputFormatstring null Format for parsing the date string daysnumber 0 Number of days for countdown hoursnumber 0 Number of hours for countdown minutesnumber 0 Number of minutes for countdown secondsnumber 0 Number of seconds for countdown datestring null Target date for countdown (e.g., “2025/05/15”) startboolean true Start countdown automatically fontSizenumber 24 Font size in pixels clsCountdownstring "" Additional CSS class for countdown element clsPartstring "" Additional CSS class for part elements clsZerostring "" Additional CSS class for zero value clsAlarmstring "" Additional CSS class for alarm state clsDaysstring "" Additional CSS class for days part clsHoursstring "" Additional CSS class for hours part clsMinutesstring "" Additional CSS class for minutes part clsSecondsstring "" Additional CSS class for seconds part onAlarmfunction Metro.noop Callback function when countdown reaches zero onTickfunction Metro.noop Callback function on each tick onZerofunction Metro.noop Callback function when a part reaches zero onBlinkfunction Metro.noop Callback function on blink onCountdownCreatefunction Metro.noop Callback function when countdown is created
start() - Start the countdown.
stop() - Stop the countdown and reset values to zero.
pause() - Pause the countdown.
resume() - Resume the countdown after pause.
reset() - Reset the countdown with the same parameters.
resetWith(val) - Reset the countdown with new parameters. val can be a date string or an object with days, hours, minutes, seconds.
togglePlay() - Toggle between play and pause states.
isPaused() - Check if the countdown is paused.
getBreakpoint(asDate) - Get the target time. If asDate is true, returns a Date object.
getLeft() - Get the remaining time in days, hours, minutes, and seconds.
blink() - Trigger the blink effect.
tick() - Manually trigger a tick.
const countdown = Metro . getPlugin ( '#myCountdown' , 'countdown' );
// Reset with a specific date
countdown . resetWith ( "2025/05/15" );
Event Description onAlarmTriggered when countdown reaches zero onTickTriggered on each tick (every second) onZeroTriggered when a part (days, hours, minutes, seconds) reaches zero onBlinkTriggered on blink effect onCountdownCreateTriggered when countdown is created
Variable Description --border-colorColor for borders and dividers between parts
.countdown - Main container class
.part - Container for each part of the countdown
.digit - Container for each digit
.digit-placeholder - Placeholder for the digit
.digit-value - Actual value of the digit
.days - Class for days part
.hours - Class for hours part
.minutes - Class for minutes part
.seconds - Class for seconds part
.blink - Class for blinking effect
.animate-slide - Class for slide animation
.animate-fade - Class for fade animation
.animate-zoom - Class for zoom animation
.no-divider - Removes the divider before a part
.d-none - Hides a part