A circular countdown timer where days, hours, minutes and seconds are shown as glowing SVG rings that shrink as time runs out. It is built with plain CSS and a small vanilla JavaScript file, and fits launch pages, event sites, sales banners and coming soon sections.
How it works
The root section.ccd-timer stores the target date in data-target (ISO 8601). Inside .ccd-grid there are four .ccd-unit elements, each marked with data-unit (days, hours, minutes or seconds). Every unit holds an SVG .ccd-ring with two circles: a faint .ccd-track and a colored .ccd-progress, plus the number .ccd-value and the .ccd-label.
The progress circle uses pathLength="100", so its stroke-dasharray is simply 100 and the visible arc equals 100 - stroke-dashoffset percent. The SVG is rotated by -90deg so the arc starts at twelve o'clock. Once per second the script calculates the remaining time and sets each ring's strokeDashoffset: hours against 24, minutes and seconds against 60, and days against data-max-days. A linear CSS transition makes the arcs shrink smoothly. When a unit wraps around (for example seconds going from 00 back to 59), the ring gets the .is-refilling class so it refills quickly instead of spinning backwards.
If data-target is missing or already in the past, the timer counts down from page load using data-fallback-days and writes the computed date into the time.ccd-time element. At zero the interval stops, the root gets .is-done and the .ccd-done message is shown.
Customization
data-targeton.ccd-timer: the launch moment, e.g.2027-03-15T09:00:00Z. Update the text of.ccd-timeto match.data-max-days: the number of days that equals a full days ring; it grows automatically if more days remain.data-fallback-days: how far ahead the demo countdown runs when the target date has passed.--ccd-days,--ccd-hours,--ccd-minutesand--ccd-seconds: the ring and label color of each unit.--ccd-ring-size: diameter of the rings; the numbers scale with it. It is7.5remon phones and9.5remfrom 640px.--ccd-stroke: thickness of the rings, for example4for a thinner, more elegant look.--ccd-bgand--ccd-bg-2: the dark background and the glow at the top of the card.- Remove the
filter: drop-shadowline in.ccd-progressfor flat rings without the neon glow.
Use cases
- Launch pages: glowing rings for days, hours, minutes and seconds count down to release
- Event sites: show time remaining until a conference or party with a done message at zero
- Sales banners: a neon countdown adds urgency to limited-time offers
- Coming soon sections: if the date has passed, the demo counts down from page load
- Accessible pages: a screen reader sentence updates every minute instead of every second
Accessibility
The visual grid is aria-hidden, because numbers that change every second are noisy for screen readers. Instead, the hidden .ccd-sr paragraph with role="timer" holds a sentence such as "77 days, 10 hours and 22 minutes remaining". It is updated only when the minute changes, and role="timer" keeps it from being announced automatically, so users can read it whenever they want. The launch date is a semantic time element. Text contrast on the dark navy background meets WCAG AA. With prefers-reduced-motion: reduce the ring transitions are switched off.
Usage notes
Several timers can share a page; each .ccd-timer reads its own attributes and keeps its own interval. Times are calculated from the visitor's clock, so add a server timestamp if the countdown must be exact.