Upsell — Trial countdown banner
A self-contained top-of-app upsell banner for the fictional Northwind SaaS, art-directed in a neutral product-UI palette with Inter type and soft shadows. It announces how long the Pro trial has left with a live-ish countdown that ticks from a fixed end timestamp, a usage progress bar, an Add billing call to action and a dismiss control. When the window runs out the banner flips to a red Trial ended variant, dismiss collapses it smoothly, and demo buttons fast-forward the timeline. Vanilla JS, aria-live polite, keyboard and Esc friendly.
MCP
Code
:root {
--brand: #5b5bf0;
--brand-d: #4646d6;
--brand-700: #3a3ab8;
--brand-50: #eef0ff;
--accent: #00b4a6;
--accent-soft: #d8f5f2;
--ink: #101322;
--ink-2: #3a4060;
--muted: #6c7393;
--bg: #f6f7fb;
--white: #ffffff;
--surface: #ffffff;
--line: rgba(16, 19, 34, 0.1);
--line-2: rgba(16, 19, 34, 0.16);
--ok: #2f9e6f;
--warn: #d98a2b;
--danger: #d4503e;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--sh-1: 0 1px 2px rgba(16, 19, 34, 0.08);
--sh-2: 0 8px 24px rgba(16, 19, 34, 0.08);
}
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
line-height: 1.5;
color: var(--ink);
background: var(--bg);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
button {
font: inherit;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--brand);
outline-offset: 2px;
border-radius: var(--r-sm);
}
/* ---------- Banner ---------- */
.banner {
position: sticky;
top: 0;
z-index: 20;
background: linear-gradient(180deg, var(--brand-50), var(--white));
border-bottom: 1px solid var(--line);
box-shadow: var(--sh-1);
overflow: hidden;
transition: opacity 0.28s ease, transform 0.28s ease;
}
.banner.is-dismissed {
height: 0 !important;
padding: 0 !important;
border-width: 0;
opacity: 0;
transform: translateY(-6px);
pointer-events: none;
}
.banner.is-expired {
background: linear-gradient(180deg, #fdeceb, var(--white));
border-bottom-color: rgba(212, 80, 62, 0.32);
}
.banner__inner {
max-width: 1080px;
margin: 0 auto;
padding: 14px 20px;
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 16px;
}
.banner__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
color: var(--brand-d);
background: var(--white);
border: 1px solid var(--line);
box-shadow: var(--sh-1);
flex: none;
}
.banner.is-expired .banner__icon {
color: var(--danger);
border-color: rgba(212, 80, 62, 0.3);
}
.banner__body {
min-width: 0;
}
.banner__head {
margin: 0;
font-size: 0.97rem;
font-weight: 600;
color: var(--ink);
}
.banner__head strong {
font-weight: 800;
}
.banner__count {
display: inline-flex;
align-items: baseline;
gap: 0.25ch;
margin-left: 2px;
padding: 1px 9px;
border-radius: 999px;
font-weight: 800;
font-variant-numeric: tabular-nums;
color: var(--brand-700);
background: var(--white);
border: 1px solid var(--line);
}
.banner.is-expired .banner__count {
color: var(--danger);
border-color: rgba(212, 80, 62, 0.28);
}
.banner__sub {
margin: 3px 0 0;
font-size: 0.84rem;
color: var(--muted);
}
/* progress */
.progress {
margin-top: 10px;
display: flex;
align-items: center;
gap: 12px;
max-width: 460px;
}
.progress__track {
position: relative;
flex: 1;
height: 8px;
border-radius: 999px;
background: rgba(91, 91, 240, 0.16);
overflow: hidden;
}
.banner.is-expired .progress__track {
background: rgba(212, 80, 62, 0.16);
}
.progress__fill {
display: block;
height: 100%;
width: 0%;
border-radius: 999px;
background: linear-gradient(90deg, var(--brand), var(--accent));
transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}
.banner.is-expired .progress__fill {
width: 100% !important;
background: linear-gradient(90deg, var(--danger), #e0735f);
}
.progress__label {
font-size: 0.76rem;
font-weight: 600;
color: var(--muted);
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.banner__actions {
display: flex;
align-items: center;
gap: 8px;
flex: none;
}
.btn {
display: inline-flex;
align-items: center;
gap: 7px;
border: 1px solid transparent;
border-radius: var(--r-sm);
padding: 9px 15px;
font-size: 0.86rem;
font-weight: 700;
transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease,
border-color 0.18s ease, color 0.18s ease;
}
.btn:active {
transform: translateY(1px);
}
.btn--cta {
color: var(--white);
background: var(--brand);
box-shadow: var(--sh-1);
}
.btn--cta:hover {
background: var(--brand-d);
box-shadow: var(--sh-2);
}
.banner.is-expired .btn--cta {
background: var(--danger);
}
.banner.is-expired .btn--cta:hover {
background: #b8412f;
}
.banner__dismiss {
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
border-radius: var(--r-sm);
border: 1px solid transparent;
background: transparent;
color: var(--ink-2);
transition: background 0.16s ease, color 0.16s ease;
}
.banner__dismiss:hover {
background: rgba(16, 19, 34, 0.06);
color: var(--ink);
}
/* ---------- App chrome ---------- */
.app {
max-width: 1080px;
margin: 0 auto;
padding: 0 20px 64px;
}
.app__bar {
display: flex;
align-items: center;
gap: 20px;
padding: 16px 0;
border-bottom: 1px solid var(--line);
}
.app__brand {
display: inline-flex;
align-items: center;
gap: 8px;
font-weight: 800;
font-size: 1.05rem;
color: var(--ink);
}
.app__brand svg {
color: var(--brand);
}
.app__nav {
display: flex;
gap: 4px;
margin-left: 8px;
}
.app__link {
padding: 7px 12px;
border-radius: var(--r-sm);
font-size: 0.86rem;
font-weight: 600;
text-decoration: none;
color: var(--muted);
transition: background 0.16s ease, color 0.16s ease;
}
.app__link:hover {
background: rgba(16, 19, 34, 0.05);
color: var(--ink);
}
.app__link.is-active {
color: var(--brand-700);
background: var(--brand-50);
}
.app__avatar {
margin-left: auto;
display: inline-flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border-radius: 50%;
font-size: 0.78rem;
font-weight: 700;
color: var(--white);
background: linear-gradient(135deg, var(--brand), var(--brand-700));
}
.app__content {
padding-top: 32px;
}
.app__welcome {
margin-bottom: 24px;
}
.app__plan {
display: inline-flex;
align-items: center;
gap: 7px;
margin: 0 0 10px;
padding: 4px 11px;
border-radius: 999px;
font-size: 0.76rem;
font-weight: 700;
letter-spacing: 0.02em;
text-transform: uppercase;
color: var(--brand-700);
background: var(--brand-50);
border: 1px solid var(--line);
}
.app__plan .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--ok);
}
.app__title {
margin: 0 0 6px;
font-size: 1.7rem;
font-weight: 800;
letter-spacing: -0.02em;
}
.app__lede {
margin: 0;
max-width: 56ch;
color: var(--ink-2);
}
.stat-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 24px;
}
.stat {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-md);
padding: 18px;
box-shadow: var(--sh-1);
}
.stat__k {
margin: 0;
font-size: 0.8rem;
font-weight: 600;
color: var(--muted);
}
.stat__v {
margin: 6px 0 2px;
font-size: 1.9rem;
font-weight: 800;
letter-spacing: -0.02em;
font-variant-numeric: tabular-nums;
}
.stat__d {
margin: 0;
font-size: 0.8rem;
color: var(--accent);
font-weight: 600;
}
.panel {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-md);
padding: 22px;
box-shadow: var(--sh-1);
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 24px;
}
.skel {
display: block;
height: 14px;
border-radius: 999px;
background: linear-gradient(
90deg,
rgba(16, 19, 34, 0.06),
rgba(16, 19, 34, 0.11),
rgba(16, 19, 34, 0.06)
);
background-size: 200% 100%;
animation: shimmer 1.6s ease-in-out infinite;
}
.skel--lg {
width: 60%;
}
.skel--md {
width: 85%;
}
.skel--sm {
width: 40%;
}
@keyframes shimmer {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
/* demo controls */
.demo {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.demo__label {
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--muted);
margin-right: 2px;
}
.demo__btn {
padding: 7px 13px;
border-radius: 999px;
border: 1px solid var(--line-2);
background: var(--white);
font-size: 0.8rem;
font-weight: 600;
color: var(--ink-2);
transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.demo__btn:hover {
background: var(--brand-50);
border-color: var(--brand);
color: var(--brand-700);
}
/* ---------- Toast ---------- */
.toast {
position: fixed;
left: 50%;
bottom: 26px;
transform: translateX(-50%) translateY(16px);
background: var(--ink);
color: var(--white);
font-size: 0.86rem;
font-weight: 600;
padding: 11px 18px;
border-radius: 999px;
box-shadow: var(--sh-2);
opacity: 0;
transition: opacity 0.22s ease, transform 0.22s ease;
z-index: 60;
max-width: calc(100vw - 32px);
}
.toast.is-show {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
/* ---------- Responsive ---------- */
@media (max-width: 760px) {
.stat-grid {
grid-template-columns: 1fr;
}
.app__nav {
display: none;
}
}
@media (max-width: 520px) {
.banner__inner {
grid-template-columns: 1fr;
gap: 12px;
padding: 14px 16px;
}
.banner__icon {
display: none;
}
.progress {
max-width: none;
}
.banner__actions {
width: 100%;
}
.btn--cta {
flex: 1;
justify-content: center;
}
.app {
padding: 0 16px 48px;
}
.app__title {
font-size: 1.4rem;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
}
}/* Northwind — Trial countdown banner
Vanilla JS. A live-ish countdown from a fixed fictional trial window,
a usage progress bar, dismiss-to-collapse, and an expired (red) variant. */
(function () {
"use strict";
var TRIAL_DAYS = 14;
var DAY_MS = 24 * 60 * 60 * 1000;
var HOUR_MS = 60 * 60 * 1000;
var MIN_MS = 60 * 1000;
// Fixed fictional timeline: trial started 11.3 days ago, so ~2 days remain.
// Kept relative to "now" so the countdown ticks live without a real backend.
var now = Date.now();
var trialStart = now - Math.round(11.3 * DAY_MS);
var trialEnd = trialStart + TRIAL_DAYS * DAY_MS;
var banner = document.getElementById("banner");
var head = document.getElementById("banner-head");
var countText = document.getElementById("count-text");
var sub = document.getElementById("banner-sub");
var fill = document.getElementById("progress-fill");
var bar = document.getElementById("progress-bar");
var progLabel = document.getElementById("progress-label");
var addBilling = document.getElementById("add-billing");
var dismiss = document.getElementById("dismiss");
var planState = document.getElementById("plan-state");
var toastEl = document.getElementById("toast");
var timer = null;
var toastTimer = null;
var expired = false;
/* ---- toast helper ---- */
function toast(msg) {
if (!toastEl) return;
toastEl.textContent = msg;
toastEl.hidden = false;
// force reflow so the transition runs on re-show
void toastEl.offsetWidth;
toastEl.classList.add("is-show");
window.clearTimeout(toastTimer);
toastTimer = window.setTimeout(function () {
toastEl.classList.remove("is-show");
window.setTimeout(function () {
toastEl.hidden = true;
}, 240);
}, 2600);
}
function plural(n, word) {
return n + " " + word + (n === 1 ? "" : "s");
}
/* ---- format the remaining-time label ---- */
function formatRemaining(ms) {
if (ms <= 0) return "0 days";
var days = Math.floor(ms / DAY_MS);
var hours = Math.floor((ms % DAY_MS) / HOUR_MS);
var mins = Math.floor((ms % HOUR_MS) / MIN_MS);
if (days >= 1) {
return plural(days, "day") + " " + plural(hours, "hr");
}
if (hours >= 1) {
return plural(hours, "hr") + " " + plural(mins, "min");
}
var secs = Math.floor((ms % MIN_MS) / 1000);
return plural(mins, "min") + " " + plural(secs, "sec");
}
/* ---- render the expired (red) state ---- */
function renderExpired() {
if (expired) return;
expired = true;
window.clearInterval(timer);
timer = null;
banner.classList.add("is-expired");
head.innerHTML = "Your <strong>Pro</strong> trial has ended";
countText.textContent = "expired";
sub.textContent =
"Pro features are paused. Add a billing method to restore analytics, SSO and your projects.";
fill.style.width = "100%";
bar.setAttribute("aria-valuenow", "100");
progLabel.textContent = "Day " + TRIAL_DAYS + " of " + TRIAL_DAYS;
if (planState) planState.textContent = "ended";
}
/* ---- render the active countdown state ---- */
function renderActive() {
var remaining = trialEnd - Date.now();
if (remaining <= 0) {
renderExpired();
return;
}
var elapsed = Date.now() - trialStart;
var pct = Math.min(100, Math.max(0, (elapsed / (trialEnd - trialStart)) * 100));
var dayNum = Math.min(TRIAL_DAYS, Math.floor(elapsed / DAY_MS) + 1);
countText.textContent = formatRemaining(remaining);
fill.style.width = pct.toFixed(1) + "%";
bar.setAttribute("aria-valuenow", String(Math.round(pct)));
progLabel.textContent = "Day " + dayNum + " of " + TRIAL_DAYS;
}
function startTicking() {
renderActive();
if (timer) window.clearInterval(timer);
// tick each second; the seconds only surface in the final minute
timer = window.setInterval(renderActive, 1000);
}
/* ---- dismiss collapses the banner ---- */
function collapse() {
var h = banner.offsetHeight;
banner.style.height = h + "px";
void banner.offsetWidth;
banner.classList.add("is-dismissed");
window.clearInterval(timer);
timer = null;
toast("Banner dismissed — find your trial under Billing.");
}
/* ---- demo jump controls ---- */
function jump(state) {
if (state === "default") {
expired = false;
banner.classList.remove("is-expired", "is-dismissed");
banner.style.height = "";
head.innerHTML =
'Your <strong>Pro</strong> trial ends in <span class="banner__count" id="count-text">14 days</span>';
countText = document.getElementById("count-text");
sub.textContent =
"Add a billing method now to keep advanced analytics, SSO and unlimited projects without interruption.";
if (planState) planState.textContent = "active";
trialStart = Date.now() - Math.round(11.3 * DAY_MS);
trialEnd = trialStart + TRIAL_DAYS * DAY_MS;
startTicking();
toast("Reset — about 2 days left on the trial.");
} else if (state === "soon") {
expired = false;
banner.classList.remove("is-expired", "is-dismissed");
banner.style.height = "";
if (planState) planState.textContent = "active";
// 25 minutes remaining, so hours/minutes show
trialEnd = Date.now() + 25 * MIN_MS;
trialStart = trialEnd - TRIAL_DAYS * DAY_MS;
startTicking();
toast("Fast-forwarded — trial ends in 25 minutes.");
} else if (state === "expired") {
banner.classList.remove("is-dismissed");
banner.style.height = "";
trialEnd = Date.now() - 5 * MIN_MS;
trialStart = trialEnd - TRIAL_DAYS * DAY_MS;
expired = false;
renderExpired();
toast("Trial forced to expired state.");
}
}
/* ---- wire events ---- */
dismiss.addEventListener("click", collapse);
addBilling.addEventListener("click", function () {
toast(
expired
? "Restoring Pro — opening secure billing…"
: "Opening secure billing to keep your Pro plan…"
);
});
// Esc dismisses the banner if it's open
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && !banner.classList.contains("is-dismissed")) {
collapse();
}
});
document.querySelectorAll(".demo__btn").forEach(function (b) {
b.addEventListener("click", function () {
jump(b.getAttribute("data-jump"));
});
});
startTicking();
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Northwind — Trial countdown banner</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- Top-of-app trial countdown banner -->
<div
class="banner"
id="banner"
role="region"
aria-label="Trial status"
aria-live="polite"
>
<div class="banner__inner">
<span class="banner__icon" id="banner-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" width="20" height="20">
<circle cx="12" cy="13" r="8" fill="none" stroke="currentColor" stroke-width="2" />
<path d="M12 9v4l2.5 2.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<path d="M9 3h6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
<div class="banner__body">
<p class="banner__head" id="banner-head">
Your <strong>Pro</strong> trial ends in
<span class="banner__count" id="count-text">14 days</span>
</p>
<p class="banner__sub" id="banner-sub">
Add a billing method now to keep advanced analytics, SSO and unlimited projects
without interruption.
</p>
<!-- Trial usage progress -->
<div class="progress" id="progress-wrap">
<div
class="progress__track"
role="progressbar"
id="progress-bar"
aria-label="Trial progress"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="0"
>
<span class="progress__fill" id="progress-fill"></span>
</div>
<span class="progress__label" id="progress-label">Day 0 of 14</span>
</div>
</div>
<div class="banner__actions">
<button type="button" class="btn btn--cta" id="add-billing">
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
<rect x="3" y="6" width="18" height="12" rx="2" fill="none" stroke="currentColor" stroke-width="2" />
<path d="M3 10h18" stroke="currentColor" stroke-width="2" />
</svg>
Add billing
</button>
<button type="button" class="banner__dismiss" id="dismiss" aria-label="Dismiss trial banner">
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">
<path d="M6 6l12 12M18 6 6 18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</button>
</div>
</div>
</div>
<!-- App chrome behind the banner, for realism -->
<main class="app" role="main">
<header class="app__bar">
<span class="app__brand">
<svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true">
<path d="M13 2 4 14h6l-1 8 9-12h-6l1-8z" fill="currentColor" />
</svg>
Northwind
</span>
<nav class="app__nav" aria-label="Primary">
<a href="#" class="app__link is-active">Overview</a>
<a href="#" class="app__link">Projects</a>
<a href="#" class="app__link">Insights</a>
<a href="#" class="app__link">Team</a>
</nav>
<span class="app__avatar" aria-hidden="true">DR</span>
</header>
<section class="app__content">
<div class="app__welcome">
<p class="app__plan">
<span class="dot" aria-hidden="true"></span>
Pro trial · <span id="plan-state">active</span>
</p>
<h1 class="app__title">Good afternoon, Dana</h1>
<p class="app__lede">
You're exploring everything in Pro. Here's a snapshot of your workspace while the
trial runs.
</p>
</div>
<div class="stat-grid">
<article class="stat">
<p class="stat__k">Active projects</p>
<p class="stat__v">12</p>
<p class="stat__d">3 added this week</p>
</article>
<article class="stat">
<p class="stat__k">Storage used</p>
<p class="stat__v">41 GB</p>
<p class="stat__d">of 100 GB on Pro</p>
</article>
<article class="stat">
<p class="stat__k">Team seats</p>
<p class="stat__v">7</p>
<p class="stat__d">2 invites pending</p>
</article>
</div>
<div class="panel" aria-hidden="true">
<span class="skel skel--lg"></span>
<span class="skel skel--md"></span>
<span class="skel skel--sm"></span>
</div>
<!-- Demo controls: simulate the trial nearing its end -->
<div class="demo" role="group" aria-label="Demo controls">
<span class="demo__label">Demo</span>
<button type="button" class="demo__btn" data-jump="default">Reset</button>
<button type="button" class="demo__btn" data-jump="soon">Ends soon</button>
<button type="button" class="demo__btn" data-jump="expired">Force expired</button>
</div>
</section>
</main>
<!-- Toast -->
<div class="toast" id="toast" role="status" aria-live="polite" hidden></div>
<script src="script.js"></script>
</body>
</html>Trial countdown banner
A sticky top-of-app banner for Northwind, a fictional SaaS, sitting above a lightly mocked
dashboard so you can see it in context. It leads with “Your Pro trial ends in N days” beside a
pill that shows the remaining time, a one-line nudge to add billing, and a gradient progress bar
that fills as the trial elapses with a Day X of 14 label. On the right are a brand-coloured Add
billing CTA and a circular dismiss X. The whole region is aria-live="polite", the progress track
carries role="progressbar" with live aria-valuenow, and every control is keyboard operable with
focus-visible rings.
The countdown is genuinely live: it runs off a fixed fictional start/end timestamp (~2 days remaining by default) and re-renders each second, surfacing days and hours normally and switching to minutes-and-seconds in the final stretch. When the clock crosses the end time the banner repaints into a red Trial ended variant — new copy, a full red progress bar and a paused plan badge below. The dismiss button (and the Esc key) collapses the banner with a smooth height-and-fade transition and raises a confirming toast.
Three demo buttons let you exercise the states without waiting: Reset restores the ~2-day window,
Ends soon fast-forwards to 25 minutes left, and Force expired jumps straight to the red state.
The layout is responsive down to ~360px — the actions go full width and the icon hides — and a
prefers-reduced-motion guard quiets the transitions. Vanilla JS only, no frameworks or build step,
and no network requests beyond the single Google Fonts link.
Illustrative UI only — Northwind, its Pro trial and all data are fictional.