Component Library

← Back to gallery

Countdown launch hero in HTML, CSS and vanilla JS

A copy-paste Countdown launch hero in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Marketing · Tags: hero, countdown, launch, deadline

Live preview

Source (copy-ready)

<section class="dcl-countdown-launch-hero" data-dcl-scheme="light" aria-labelledby="dcl-countdown-launch-hero-title"><header class="dcl-countdown-launch-hero__header"><h2 id="dcl-countdown-launch-hero-title">Countdown launch hero</h2><p class="dcl-countdown-launch-hero__muted">A live operational deadline anchors migration preparation.</p></header><p class="dcl-countdown-launch-hero__eyebrow">Migration window</p><h3>Customer workspace migration opens soon.</h3><p>Freeze editing, validate the sample and keep rollback available through the window.</p><p class="dcl-countdown-launch-hero__count" role="status" aria-live="polite" data-count>3 days 00:00:00 remaining</p><a class="dcl-countdown-launch-hero__cta" href="#dcl-countdown-launch-hero-prep">Review preparation</a><section id="dcl-countdown-launch-hero-prep" tabindex="-1"><h3>Preparation</h3><p>Confirm the freeze owner and rollback contact.</p></section><script>(()=>{const root=document.currentScript.closest(".dcl-countdown-launch-hero");if(!root||root.dataset.dclBound)return;root.dataset.dclBound="1";const instance=Array.from(document.getElementsByClassName("dcl-countdown-launch-hero")).indexOf(root);if(instance>0){for(const el of [root,...root.querySelectorAll("*")]){for(const attr of ["id","aria-labelledby","aria-controls","aria-describedby","for","name"]){if(el.hasAttribute(attr))el.setAttribute(attr,el.getAttribute(attr)+"--"+instance)}const href=el.getAttribute("href");if(href&&href.startsWith("#"))el.setAttribute("href",href+"--"+instance)}}const preference=matchMedia("(prefers-color-scheme: dark)"),apply=()=>{root.dataset.dclScheme=preference.matches?"dark":"light"};preference.addEventListener("change",apply);apply();const q=(s)=>root.querySelector(s),qa=(s)=>Array.from(root.querySelectorAll(s));const target=Date.now()+3*86400000+2*3600000,count=q("[data-count]");function tick(){let s=Math.max(0,Math.floor((target-Date.now())/1000));const d=Math.floor(s/86400);s-=d*86400;const h=String(Math.floor(s/3600)).padStart(2,"0"),m=String(Math.floor(s%3600/60)).padStart(2,"0"),sec=String(s%60).padStart(2,"0");count.textContent=d+" days "+h+":"+m+":"+sec+" remaining"}tick();setInterval(tick,1000);})();</script></section>
<style>
.dcl-countdown-launch-hero{color:#11292f;background-color:#ffffff;color-scheme:light;font:1rem/1.45 system-ui,sans-serif;padding:.8rem;border:1px solid #697f84;border-radius:.6rem;overflow-wrap:anywhere}
.dcl-countdown-launch-hero *{box-sizing:border-box}.dcl-countdown-launch-hero h2,.dcl-countdown-launch-hero h3{line-height:1.15;margin-block:0 .6rem}.dcl-countdown-launch-hero a{color:#005c62}
.dcl-countdown-launch-hero button,.dcl-countdown-launch-hero input,.dcl-countdown-launch-hero select,.dcl-countdown-launch-hero textarea,.dcl-countdown-launch-hero summary{min-block-size:44px;border:1px solid #697f84;border-radius:.3rem;padding:.4rem .65rem;font:inherit;color:#11292f;background-color:#e4edef}
.dcl-countdown-launch-hero input,.dcl-countdown-launch-hero select,.dcl-countdown-launch-hero textarea{background-color:#ffffff}.dcl-countdown-launch-hero input[type="radio"],.dcl-countdown-launch-hero input[type="checkbox"]{min-block-size:auto;inline-size:auto}
.dcl-countdown-launch-hero button,.dcl-countdown-launch-hero summary{cursor:pointer}.dcl-countdown-launch-hero button:hover,.dcl-countdown-launch-hero summary:hover{color:#ffffff;background-color:#00535a}
.dcl-countdown-launch-hero button:focus-visible,.dcl-countdown-launch-hero input:focus-visible,.dcl-countdown-launch-hero select:focus-visible,.dcl-countdown-launch-hero textarea:focus-visible,.dcl-countdown-launch-hero summary:focus-visible,.dcl-countdown-launch-hero a:focus-visible{outline:3px solid #005c62;outline-offset:2px}
.dcl-countdown-launch-hero details{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.4rem;margin-block-start:.6rem}.dcl-countdown-launch-hero summary{font-weight:650}
.dcl-countdown-launch-hero dialog{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.6rem;max-inline-size:min(34rem,92vw);padding:1rem}
.dcl-countdown-launch-hero table{border-collapse:collapse;inline-size:100%;color:#11292f;background-color:#ffffff}.dcl-countdown-launch-hero th,.dcl-countdown-launch-hero td{padding:.4rem;text-align:start;border-block-end:1px solid #697f84}.dcl-countdown-launch-hero th{color:#11292f;background-color:#e4edef}
.dcl-countdown-launch-hero [hidden]{display:none!important}.dcl-countdown-launch-hero__muted{color:#405a60}.dcl-countdown-launch-hero__panel{color:#405a60;background-color:#ffffff}.dcl-countdown-launch-hero__well{color:#11292f;background-color:#e4edef}.dcl-countdown-launch-hero__primary,.dcl-countdown-launch-hero__badge{color:#ffffff;background-color:#00535a}.dcl-countdown-launch-hero__badge{border-radius:999px;padding:.1rem .45rem;font-size:.8rem;font-weight:700}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"]{color:#eff8f9;background-color:#142f36;color-scheme:dark;border-color:#839fa5}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] a{color:#8fe1da}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"] button,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] input,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] select,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] textarea,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] summary{color:#eff8f9;background-color:#1c3c44;border-color:#839fa5}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"] input,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] select,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] textarea{background-color:#142f36}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] button:hover,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] summary:hover{color:#11292f;background-color:#8fe1da}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"] button:focus-visible,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] input:focus-visible,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] select:focus-visible,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] textarea:focus-visible,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] summary:focus-visible,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] a:focus-visible{outline-color:#8fe1da}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"] details,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] dialog,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] table{color:#eff8f9;background-color:#142f36;border-color:#839fa5}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] th{color:#eff8f9;background-color:#1c3c44}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] th,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] td{border-color:#839fa5}
.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__muted{color:#b0c9ce}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__panel{color:#b0c9ce;background-color:#142f36}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__well{color:#eff8f9;background-color:#1c3c44}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__primary,.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__badge{color:#11292f;background-color:#8fe1da}
@media (prefers-reduced-motion:reduce){.dcl-countdown-launch-hero *{transition:none!important;animation:none!important}}
.dcl-countdown-launch-hero__count{font-size:clamp(1.7rem,4vw,3rem);font-weight:800;color:#11292f;background-color:#e4edef;border-radius:.5rem;padding:.8rem}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero__count{color:#eff8f9;background-color:#1c3c44}.dcl-countdown-launch-hero a.dcl-countdown-launch-hero__cta{display:inline-block;min-block-size:44px;padding:.55rem .8rem;border-radius:.4rem;color:#ffffff;background-color:#00535a}.dcl-countdown-launch-hero[data-dcl-scheme="dark"] .dcl-countdown-launch-hero a.dcl-countdown-launch-hero__cta{color:#11292f;background-color:#8fe1da}</style>

When to use

Use for a real scheduled operational deadline. Update no faster than once per second and keep the preparation action adjacent.

Avoid

Do not use urgency countdowns for artificial marketing pressure or resets that never expire.

Accessibility

Remaining time is plain text in a live region rather than digits communicated by motion or color alone. Hero copy and controls remain selectable text with visible focus. Light body text is #405a60 on #ffffff (7.37:1) and headings #11292f on #ffffff (15.19:1); dark equivalents are #b0c9ce on #142f36 (8.12:1) and #eff8f9 on #142f36 (13.07:1).

Was this useful? Send feedback.