Countdown Timer
Counts down to a date and time in days, hours, minutes and seconds, and fires an event at zero.
<arc-countdown-timer>Overview
CountdownTimer counts down to the date in target, which takes an ISO 8601 string or anything new Date() can parse. A date and time without a time zone is read as the visitor's local time, but a date on its own, such as 2027-01-01, is read as midnight UTC. The display is four segments, labeled Days, Hours, Min and Sec, with colons between them. Each number is at least two mono digits with tabular-nums, so the width doesn't change as it ticks. A countdown of 100 days or more shows three digits of days.
It recalculates every second and stops its interval when removed from the page. At zero it fires arc-expired once and replaces the segments with the expired text, which defaults to "Expired". Setting a new target starts it again.
label adds an uppercase line above the countdown, such as "Sale ends". hide-zero-segments hides segments whose value is zero, so a countdown under a day drops the Days segment.
Guidelines
Do
- Use it for event countdowns, product launches and sale deadlines
- Set a `label` that says what's being counted down to, such as "Launches in" or "Offer ends"
- Set `expired` to text that fits, such as "Now live"
Don't
- Don't use it for elapsed time or as a stopwatch. It only counts down
- Don't set a target in the past unless you want the expired text straight away
- Don't enforce deadlines with it. Check them on the server
Features
- Numbers use the accent text gradient, and segments get the interactive hover shadow
- CSS parts: `container`, `segment`, `number`, `label`, `separator`
Preview
Usage
Countdown Timer is in the marketing group, so the default @arclux/arc-ui entry point doesn't include it. Import it from@arclux/arc-ui/marketing or from its own subpath,@arclux/arc-ui/countdown-timer.
This component needs JavaScript. Use the Web Component or a framework wrapper.
<!-- New Year countdown -->
<arc-countdown-timer
target="2026-12-31T00:00:00"
label="New Year"
></arc-countdown-timer>
<!-- Product launch with custom expired text -->
<arc-countdown-timer
target="2026-06-15T09:00:00"
label="Launches In"
expired="Now Live!"
></arc-countdown-timer>
<!-- Short countdown, hiding zero segments -->
<arc-countdown-timer
target="2026-03-01T18:00:00"
hide-zero-segments
></arc-countdown-timer>import { CountdownTimer } from '@arclux/arc-ui-react';
function LaunchBanner({ launchDate }) {
return (
<CountdownTimer
target={launchDate}
label="Launches In"
expired="Now Live!"
onArcExpired={() => console.log('Countdown finished!')}
/>
);
}<script setup>
import { CountdownTimer } from '@arclux/arc-ui-vue';
const launchDate = '2026-12-31T00:00:00';
function handleExpired() {
console.log('Countdown finished!');
}
</script>
<template>
<CountdownTimer
:target="launchDate"
label="New Year"
expired="Happy New Year!"
@arc-expired="handleExpired"
/>
</template><script>
import { CountdownTimer } from '@arclux/arc-ui-svelte';
const target = '2026-12-31T00:00:00';
</script>
<CountdownTimer
{target}
label="New Year"
expired="Happy New Year!"
on:arc-expired={() => console.log('Done!')}
/>import { Component } from '@angular/core';
import { CountdownTimer } from '@arclux/arc-ui-angular';
@Component({
imports: [CountdownTimer],
template: `
<arc-countdown-timer
target="2026-12-31T00:00:00"
label="New Year"
expired="Happy New Year!"
(arc-expired)="onExpired()"
/>
`,
})
export class CountdownComponent {
onExpired() {
console.log('Countdown finished!');
}
}import { CountdownTimer } from '@arclux/arc-ui-solid';
function LaunchCountdown() {
return (
<CountdownTimer
target="2026-12-31T00:00:00"
label="New Year"
expired="Happy New Year!"
/>
);
}import { CountdownTimer } from '@arclux/arc-ui-preact';
function LaunchCountdown() {
return (
<CountdownTimer
target="2026-12-31T00:00:00"
label="New Year"
expired="Happy New Year!"
/>
);
}API
targetstring''- ISO date string or parseable date for the countdown target
labelstring''- Optional label displayed above the countdown
expiredstring'Expired'- Text shown when the countdown reaches zero
hideZeroSegmentsbooleanfalse- Hide leading segments that are zero
Events
arc-expired- Fired when the countdown reaches zero