Progress timeout toast in HTML, CSS and vanilla JS
A copy-paste Progress timeout toast in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-progress-timeout-toast" data-dcl-scheme="light" aria-labelledby="dcl-progress-timeout-toast-title"><header class="dcl-progress-timeout-toast__header"><h2 id="dcl-progress-timeout-toast-title">Progress timeout toast</h2><p class="dcl-progress-timeout-toast__muted">A transient notice shows remaining time and pauses on interaction.</p></header><button type="button" data-show>Show export toast</button><div class="dcl-progress-timeout-toast__toast" data-toast hidden><p><strong>Export ready.</strong> This notice closes in <span data-count>6</span> seconds.</p><div class="dcl-progress-timeout-toast__bar" data-bar></div><button type="button" data-dismiss>Dismiss</button></div><script>(()=>{const root=document.currentScript.closest(".dcl-progress-timeout-toast");if(!root||root.dataset.dclBound)return;root.dataset.dclBound="1";const instance=Array.from(document.getElementsByClassName("dcl-progress-timeout-toast")).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 toast=q("[data-toast]"),bar=q("[data-bar]"),count=q("[data-count]");let left,timer;function clear(){clearInterval(timer)}function close(){clear();toast.hidden=true}function tick(){left-=.2;count.textContent=Math.ceil(left);bar.style.width=Math.max(0,left/6*100)+"%";if(left<=0)close()}q("[data-show]").addEventListener("click",()=>{left=6;toast.hidden=false;clear();timer=setInterval(tick,200)});q("[data-dismiss]").addEventListener("click",close);toast.addEventListener("mouseenter",clear);toast.addEventListener("focusin",clear);})();</script></section>
<style>
.dcl-progress-timeout-toast{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-progress-timeout-toast *{box-sizing:border-box}.dcl-progress-timeout-toast h2,.dcl-progress-timeout-toast h3{line-height:1.15;margin-block:0 .6rem}.dcl-progress-timeout-toast a{color:#005c62}
.dcl-progress-timeout-toast button,.dcl-progress-timeout-toast input,.dcl-progress-timeout-toast select,.dcl-progress-timeout-toast textarea,.dcl-progress-timeout-toast summary{min-block-size:44px;border:1px solid #697f84;border-radius:.3rem;padding:.4rem .65rem;font:inherit;color:#11292f;background-color:#e4edef}
.dcl-progress-timeout-toast input,.dcl-progress-timeout-toast select,.dcl-progress-timeout-toast textarea{background-color:#ffffff}.dcl-progress-timeout-toast input[type="radio"],.dcl-progress-timeout-toast input[type="checkbox"]{min-block-size:auto;inline-size:auto}
.dcl-progress-timeout-toast button,.dcl-progress-timeout-toast summary{cursor:pointer}.dcl-progress-timeout-toast button:hover,.dcl-progress-timeout-toast summary:hover{color:#ffffff;background-color:#00535a}
.dcl-progress-timeout-toast button:focus-visible,.dcl-progress-timeout-toast input:focus-visible,.dcl-progress-timeout-toast select:focus-visible,.dcl-progress-timeout-toast textarea:focus-visible,.dcl-progress-timeout-toast summary:focus-visible,.dcl-progress-timeout-toast a:focus-visible{outline:3px solid #005c62;outline-offset:2px}
.dcl-progress-timeout-toast details{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.4rem;margin-block-start:.6rem}.dcl-progress-timeout-toast summary{font-weight:650}
.dcl-progress-timeout-toast dialog{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.6rem;max-inline-size:min(34rem,92vw);padding:1rem}
.dcl-progress-timeout-toast table{border-collapse:collapse;inline-size:100%;color:#11292f;background-color:#ffffff}.dcl-progress-timeout-toast th,.dcl-progress-timeout-toast td{padding:.4rem;text-align:start;border-block-end:1px solid #697f84}.dcl-progress-timeout-toast th{color:#11292f;background-color:#e4edef}
.dcl-progress-timeout-toast [hidden]{display:none!important}.dcl-progress-timeout-toast__muted{color:#405a60}.dcl-progress-timeout-toast__panel{color:#405a60;background-color:#ffffff}.dcl-progress-timeout-toast__well{color:#11292f;background-color:#e4edef}.dcl-progress-timeout-toast__primary,.dcl-progress-timeout-toast__badge{color:#ffffff;background-color:#00535a}.dcl-progress-timeout-toast__badge{border-radius:999px;padding:.1rem .45rem;font-size:.8rem;font-weight:700}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"]{color:#eff8f9;background-color:#142f36;color-scheme:dark;border-color:#839fa5}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] a{color:#8fe1da}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"] button,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] input,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] select,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] textarea,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] summary{color:#eff8f9;background-color:#1c3c44;border-color:#839fa5}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"] input,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] select,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] textarea{background-color:#142f36}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] button:hover,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] summary:hover{color:#11292f;background-color:#8fe1da}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"] button:focus-visible,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] input:focus-visible,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] select:focus-visible,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] textarea:focus-visible,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] summary:focus-visible,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] a:focus-visible{outline-color:#8fe1da}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"] details,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] dialog,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] table{color:#eff8f9;background-color:#142f36;border-color:#839fa5}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] th{color:#eff8f9;background-color:#1c3c44}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] th,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] td{border-color:#839fa5}
.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__muted{color:#b0c9ce}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__panel{color:#b0c9ce;background-color:#142f36}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__well{color:#eff8f9;background-color:#1c3c44}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__primary,.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__badge{color:#11292f;background-color:#8fe1da}
@media (prefers-reduced-motion:reduce){.dcl-progress-timeout-toast *{transition:none!important;animation:none!important}}
.dcl-progress-timeout-toast__toast{position:relative;margin-block-start:1rem;border:1px solid #697f84;border-radius:.45rem;padding:.7rem;color:#11292f;background-color:#e4edef}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__toast{color:#eff8f9;background-color:#1c3c44}.dcl-progress-timeout-toast__bar{block-size:.3rem;background-color:#00535a;width:100%}.dcl-progress-timeout-toast[data-dcl-scheme="dark"] .dcl-progress-timeout-toast__bar{background-color:#8fe1da}.dcl-progress-timeout-toast__toast[hidden]{display:none}</style>
When to use
Use only for genuinely transient confirmation that users may need time to read. Pause whenever the user interacts with the notification.
Avoid
Do not auto-dismiss errors, undo opportunities, or anything whose loss would leave the user uncertain what happened.
Accessibility
The remaining time is visible as text, dismissal is a real button, and hovering or focusing the toast stops automatic removal. Status text is written text rather than colour alone and focus is visibly outlined. Light text is #11292f or #405a60 on the surface (15.19:1/7.37:1); dark text is #eff8f9 or #b0c9ce on the dark surface (13.07:1/8.12:1).
Was this useful? Send feedback.