Deadline Banner 1
Counts down to a real price deadline so the visitor buys before the price rises.
Use it in a prompt
Use urgency/deadline-banner from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/urgency/deadline-banner.tsx. - Import it and pass your copy and images (Props tab):
import { DeadlineBanner } from "@/components/funneldna/urgency/deadline-banner"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/urgency/deadline-banner/component.tsx 536 lines
// Counts down to a real price deadline so the visitor buys before the price rises.
// layout: classic-centred-stack
// Deadline banner: counts down to a real, supplied price deadline beside today's price and the price it returns to, so the visitor acts before it rises.
import * as React from "react"
import { AlarmClock, Loader2, Lock } from "lucide-react"
export type DeadlineBannerProps = {
/** The real moment the price rises (ISO string, epoch ms or Date). Without a valid deadline the banner renders nothing. */
deadline?: string | number | Date
/** Length of the price window the fuse bar measures, in hours. */
windowHours?: number
headline?: React.ReactNode
/** Headline once the deadline has passed. */
expiredHeadline?: React.ReactNode
/** Lead line. Placeholders: {name}, {price}, {regularPrice}. */
lead?: string
/** Lead line once the deadline has passed. Same placeholders. */
expiredLead?: string
productName?: string
/** Today's price. */
price?: string
/** The price after the deadline. */
regularPrice?: string
regularLabel?: string
/** Savings line. Placeholder: {amount}. */
savingsTemplate?: string
/** Label above the price once the deadline has passed. */
currentLabel?: string
timerLabel?: string
/** Spoken after the remaining time, e.g. "3 hours, 12 minutes, 5 seconds left at this price". */
timerSuffix?: string
expiredTimerLabel?: string
units?: { days: string; hours: string; minutes: string; seconds: string }
label?: string
/** Button label once the deadline has passed. Placeholder: {regularPrice}. */
expiredLabel?: string
loadingLabel?: string
sublabel?: string
href?: string
onAction?: () => void
disabled?: boolean
/** Shows a busy button while the page opens checkout. */
loading?: boolean
state?: "default" | "hover" | "active" | "disabled"
className?: string
}
export function DeadlineBanner(props: DeadlineBannerProps) {
const {
deadline,
windowHours = 24,
headline = (
<>
Price goes up at <span className="cf-deadline-banner__mark">midnight</span>
</>
),
expiredHeadline = "The price has gone up",
lead = "Get {name} for {price} today. At midnight it goes back to {regularPrice}.",
expiredLead = "{name} is now {regularPrice}.",
productName = "The Funnel Starter Kit",
price = "$47",
regularPrice = "$97",
regularLabel = "Regularly",
savingsTemplate = "Save {amount} today",
currentLabel = "Current price",
timerLabel = "Time left at this price",
timerSuffix = "left at this price",
expiredTimerLabel = "This price has ended",
units = { days: "Days", hours: "Hours", minutes: "Minutes", seconds: "Seconds" },
label = "Yes! Give Me Instant Access",
expiredLabel = "Get Instant Access for {regularPrice}",
loadingLabel = "Opening secure checkout…",
sublabel = "",
href,
onAction,
disabled = false,
loading = false,
state = "default",
className,
} = props
const id = React.useId()
const target = React.useMemo(() => toTime(deadline), [deadline])
const [now, setNow] = React.useState(() => Date.now())
React.useEffect(() => {
if (!Number.isFinite(target)) return
setNow(Date.now())
if (target <= Date.now()) return
const timer = window.setInterval(() => {
const t = Date.now()
setNow(t)
if (t >= target) window.clearInterval(timer)
}, 1000)
return () => window.clearInterval(timer)
}, [target])
if (!Number.isFinite(target)) return null
const remaining = Math.max(0, target - now)
const expired = remaining <= 0
const total = Math.floor(remaining / 1000)
const d = Math.floor(total / 86400)
const h = Math.floor((total % 86400) / 3600)
const m = Math.floor((total % 3600) / 60)
const s = total % 60
const clock =
d > 0
? [
{ key: "d", n: d, label: units.days },
{ key: "h", n: h, label: units.hours },
{ key: "m", n: m, label: units.minutes },
]
: [
{ key: "h", n: h, label: units.hours },
{ key: "m", n: m, label: units.minutes },
{ key: "s", n: s, label: units.seconds },
]
const spoken = clock.map((u) => `${u.n} ${u.label.toLowerCase()}`).join(", ") + " " + timerSuffix
const windowMs = Math.max(1, windowHours) * 3600000
const fill = expired ? 1 : Math.min(1, Math.max(0, 1 - remaining / windowMs))
const vars = { name: productName, price, regularPrice }
const savings = savingsLine(price, regularPrice, savingsTemplate)
const isDisabled = disabled || state === "disabled"
const buttonLabel = loading ? loadingLabel : expired ? fillText(expiredLabel, vars) : label
const rootClass = [
"cf-deadline-banner",
expired ? "is-expired" : "",
state === "hover" ? "is-hover" : "",
state === "active" ? "is-active" : "",
className ?? "",
]
.filter(Boolean)
.join(" ")
const inner = (
<>
{loading ? <Loader2 className="cf-deadline-banner__spin" aria-hidden /> : null}
<span className="cf-deadline-banner__btn-label">{buttonLabel}</span>
</>
)
const button =
href && !isDisabled && !loading ? (
<a className="cf-deadline-banner__btn" href={href} onClick={() => onAction?.()}>
{inner}
</a>
) : (
<button
type="button"
className={"cf-deadline-banner__btn" + (loading ? " is-loading" : "")}
disabled={isDisabled}
aria-busy={loading || undefined}
onClick={() => {
if (!loading) onAction?.()
}}
>
{inner}
</button>
)
return (
<section className={rootClass} aria-labelledby={`${id}-h`}>
<style>{css}</style>
<h2 id={`${id}-h`} className="cf-deadline-banner__headline">
{expired ? expiredHeadline : headline}
</h2>
<p className="cf-deadline-banner__lead">{fillText(expired ? expiredLead : lead, vars)}</p>
<div className="cf-deadline-banner__board">
<div className="cf-deadline-banner__timer">
<p className="cf-deadline-banner__timer-label">
<AlarmClock aria-hidden />
{expired ? expiredTimerLabel : timerLabel}
</p>
<div
className="cf-deadline-banner__clock"
role="timer"
aria-live="off"
aria-label={expired ? expiredTimerLabel : spoken}
>
{clock.map((u, i) => (
<React.Fragment key={u.key}>
{i > 0 ? (
<span className="cf-deadline-banner__colon" aria-hidden>
:
</span>
) : null}
<span className="cf-deadline-banner__unit" aria-hidden>
<span className="cf-deadline-banner__tile">
<span className="cf-deadline-banner__digits" key={u.n}>
{String(u.n).padStart(2, "0")}
</span>
</span>
<span className="cf-deadline-banner__unit-label">{u.label}</span>
</span>
</React.Fragment>
))}
</div>
<div className="cf-deadline-banner__fuse" aria-hidden>
<span style={{ ["--dl-fill" as string]: String(fill) } as React.CSSProperties} />
</div>
</div>
<span className="cf-deadline-banner__divider" aria-hidden />
<div className="cf-deadline-banner__price">
{expired ? (
<p className="cf-deadline-banner__was">{currentLabel}</p>
) : (
<p className="cf-deadline-banner__was">
{regularLabel} <s>{regularPrice}</s>
</p>
)}
<p className={"cf-deadline-banner__now" + (!expired && savings ? " has-save" : "")}>
{expired ? regularPrice : price}
</p>
{!expired && savings ? <p className="cf-deadline-banner__save">{savings}</p> : null}
</div>
</div>
<div className="cf-deadline-banner__action">
{button}
{sublabel ? (
<p className="cf-deadline-banner__reassure">
<Lock aria-hidden />
{sublabel}
</p>
) : null}
</div>
</section>
)
}
export default DeadlineBanner
function toTime(value: DeadlineBannerProps["deadline"]): number {
if (value === undefined || value === null || value === "") return NaN
if (value instanceof Date) return value.getTime()
if (typeof value === "number") return value
return Date.parse(value)
}
function fillText(template: string, vars: Record<string, string>): string {
return Object.entries(vars).reduce((text, [key, val]) => text.split(`{${key}}`).join(val), template)
}
function savingsLine(price: string, regular: string, template: string): string | null {
const now = parseFloat(price.replace(/[^0-9.]/g, ""))
const was = parseFloat(regular.replace(/[^0-9.]/g, ""))
if (!Number.isFinite(now) || !Number.isFinite(was) || was <= now) return null
const prefix = (price.match(/^[^0-9]*/) ?? [""])[0]
const diff = was - now
const amount = prefix + (Number.isInteger(diff) ? String(diff) : diff.toFixed(2))
return fillText(template, { amount })
}
const css = `
.cf-deadline-banner {
--dl-marker: var(--marker, #fae37c);
--dl-radius: var(--card-radius, calc(var(--radius, 12px) * 1.5));
--dl-btn: var(--button-bg, var(--cta));
--dl-btn-2: var(--button-bg-2, var(--cta-2));
--dl-shadow: var(--shadow, oklch(0.22 0.03 256));
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 60rem;
margin-inline: auto;
padding: clamp(1.75rem, 4vw, 3rem) clamp(1rem, 4vw, 3.25rem);
background: var(--card, #ffffff);
color: var(--ink);
border: 1px solid var(--card-border, color-mix(in oklch, var(--ink) 12%, transparent));
border-radius: var(--dl-radius);
box-shadow: var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 256 / 0.22), 0 12px 24px -8px oklch(0.22 0.03 256 / 0.32))), inset 0 1px 0 oklch(from var(--card, #ffffff) calc(l + 0.04) c h / 0.6);
font-family: var(--font-body);
text-align: center;
}
.cf-deadline-banner *, .cf-deadline-banner *::before, .cf-deadline-banner *::after { box-sizing: border-box; }
.cf-deadline-banner p { margin: 0; }
.cf-deadline-banner__headline {
margin: 0 0 1rem;
color: var(--ink);
font-family: var(--font-display);
font-size: clamp(2.1rem, 5.4vw, 3.75rem);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
letter-spacing: var(--display-tracking, -0.02em);
line-height: 1.04;
text-wrap: balance;
}
.cf-deadline-banner__mark {
padding: 0 0.1em;
background-image: linear-gradient(176deg, transparent 0 50%, color-mix(in oklch, var(--dl-marker) 78%, transparent) 50% 90%, transparent 90%);
border-radius: 0.1em 0.22em 0.14em 0.25em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
.cf-deadline-banner__lead {
max-width: 40rem;
margin-inline: auto !important;
color: var(--muted);
font-size: clamp(1.05rem, 1.6vw, 1.25rem);
font-weight: 500;
line-height: 1.5;
text-wrap: pretty;
}
.cf-deadline-banner__board {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 1.5rem;
margin-top: clamp(1.5rem, 3vw, 2.25rem);
padding: clamp(1.25rem, 3vw, 1.75rem) clamp(0.75rem, 3vw, 1.75rem);
background: color-mix(in oklch, var(--ink) 4%, var(--card, #ffffff));
border-radius: calc(var(--dl-radius) - 4px);
}
.cf-deadline-banner__divider {
display: block;
height: 1px;
background: oklch(from var(--ink) l c h / 0.14);
}
.cf-deadline-banner__timer-label {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
margin-bottom: 0.9rem !important;
color: var(--ink);
font-size: 0.95rem;
font-weight: 700;
line-height: 1.3;
}
.cf-deadline-banner__timer-label svg { width: 1.15em; height: 1.15em; flex: none; color: var(--warning); stroke-width: 2.4; }
.cf-deadline-banner__clock {
display: flex;
justify-content: center;
align-items: flex-start;
gap: 0.45rem;
}
.cf-deadline-banner__unit { display: grid; justify-items: center; gap: 0.5rem; }
.cf-deadline-banner__tile {
display: grid;
place-items: center;
min-width: 4.75rem;
padding: 0.7rem 0.7rem 0.62rem;
overflow: hidden;
background: linear-gradient(180deg, oklch(from var(--band) calc(l + 0.05) c h), var(--band));
color: var(--band-ink);
border-radius: calc(var(--radius, 12px) * 0.9);
box-shadow: inset 0 1px 0 oklch(from var(--band) calc(l + 0.14) c h / 0.7), inset 0 -2px 0 oklch(from var(--band) calc(l - 0.08) c h), var(--shadow-sm, 0 1px 2px oklch(0.22 0.03 256 / 0.25));
}
.cf-deadline-banner__digits {
display: block;
font-family: var(--font-display);
font-size: clamp(2rem, 4.2vw, 2.75rem);
font-weight: var(--display-weight, 800);
font-variant-numeric: tabular-nums;
letter-spacing: -0.02em;
line-height: 1;
animation: cf-dl-tick 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cf-deadline-banner__unit-label {
color: var(--muted);
font-size: 0.875rem;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.cf-deadline-banner__colon {
padding-top: 0.6rem;
color: var(--muted);
font-family: var(--font-display);
font-size: 2rem;
font-weight: 800;
line-height: 1;
}
.cf-deadline-banner__fuse {
max-width: 20rem;
height: 0.5rem;
margin: 1.15rem auto 0;
overflow: hidden;
background: color-mix(in oklch, var(--ink) 10%, var(--card, #ffffff));
border-radius: 999px;
}
.cf-deadline-banner__fuse span {
display: block;
height: 100%;
background: linear-gradient(90deg, oklch(from var(--warning) calc(l + 0.14) c h), var(--warning));
border-radius: inherit;
transform: scaleX(var(--dl-fill, 0));
transform-origin: left center;
transition: transform 1s linear;
}
.cf-deadline-banner__price { display: flex; flex-direction: column; align-items: center; }
.cf-deadline-banner__was {
color: var(--muted);
font-size: 1.05rem;
font-weight: 600;
line-height: 1.3;
}
.cf-deadline-banner__was s {
color: var(--ink);
font-weight: 700;
text-decoration-color: var(--danger);
text-decoration-thickness: 0.12em;
}
.cf-deadline-banner__now {
margin-top: 0.35rem !important;
color: var(--ink);
font-family: var(--font-display);
font-size: clamp(3.25rem, 7vw, 4.75rem);
font-weight: var(--display-weight, 800);
font-variant-numeric: tabular-nums;
letter-spacing: -0.03em;
line-height: 1;
}
.cf-deadline-banner__now.has-save { margin-bottom: 0.85rem !important; }
.cf-deadline-banner__save {
display: inline-flex;
align-items: center;
padding: 0.35rem 0.9rem;
background: var(--success-soft);
color: var(--success);
border-radius: 999px;
font-size: 0.95rem;
font-weight: 800;
line-height: 1.3;
}
.cf-deadline-banner__action { margin-top: clamp(1.5rem, 3vw, 2rem); }
.cf-deadline-banner__btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.6rem;
width: 100%;
max-width: 30rem;
min-height: 4rem;
margin-inline: auto;
padding: 1rem 1.75rem;
border: 1px solid oklch(from var(--dl-btn) calc(l - 0.12) c h);
border-radius: var(--button-radius, var(--radius, 12px));
background: linear-gradient(180deg, oklch(from var(--dl-btn) calc(l + 0.04) c h), var(--dl-btn-2));
color: var(--button-ink, var(--cta-ink));
font-family: var(--button-font, var(--font-display));
font-size: clamp(1.15rem, 2.2vw, 1.4rem);
font-weight: var(--button-weight, 800);
text-transform: var(--button-case, none);
line-height: 1.15;
text-align: center;
text-decoration: none;
text-shadow: var(--button-text-shadow, none);
text-wrap: balance;
cursor: pointer;
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--dl-btn) calc(l + 0.14) c h / 0.7), inset 0 -3px 0 oklch(from var(--dl-btn) calc(l - 0.16) c h), 0 1px 2px oklch(from var(--dl-shadow) l c h / 0.3), 0 6px 14px -4px oklch(from var(--dl-shadow) l c h / 0.35));
transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.cf-deadline-banner__btn:hover:not(:disabled),
.cf-deadline-banner.is-hover .cf-deadline-banner__btn:not(:disabled) {
transform: translateY(-1px);
background: linear-gradient(180deg, var(--dl-btn), oklch(from var(--dl-btn-2) calc(l - 0.06) c h));
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--dl-btn) calc(l + 0.12) c h / 0.7), inset 0 -3px 0 oklch(from var(--dl-btn) calc(l - 0.2) c h), 0 2px 3px oklch(from var(--dl-shadow) l c h / 0.32), 0 9px 18px -5px oklch(from var(--dl-shadow) l c h / 0.4));
}
.cf-deadline-banner__btn:active:not(:disabled),
.cf-deadline-banner.is-active .cf-deadline-banner__btn:not(:disabled) {
transform: translateY(1px);
background: linear-gradient(180deg, oklch(from var(--dl-btn-2) calc(l - 0.04) c h), oklch(from var(--dl-btn-2) calc(l - 0.08) c h));
box-shadow: inset 0 2px 4px oklch(from var(--dl-btn) calc(l - 0.22) c h / 0.55), 0 1px 1px oklch(from var(--dl-shadow) l c h / 0.3);
}
.cf-deadline-banner__btn:focus-visible {
outline: 3px solid var(--field-focus, var(--accent));
outline-offset: 3px;
}
.cf-deadline-banner__btn:disabled {
background: var(--button-2-bg, var(--secondary));
color: var(--button-2-ink, var(--secondary-ink));
border-color: transparent;
text-shadow: none;
cursor: not-allowed;
transform: none;
box-shadow: var(--button-2-shadow, var(--shadow-sm));
}
.cf-deadline-banner__btn.is-loading { cursor: progress; }
.cf-deadline-banner__spin { width: 1.2em; height: 1.2em; flex: none; animation: cf-dl-spin 0.9s linear infinite; }
.cf-deadline-banner__reassure {
display: flex;
align-items: center;
justify-content: center;
gap: 0.45rem;
margin-top: 0.85rem !important;
color: var(--muted);
font-size: 0.95rem;
font-weight: 600;
line-height: 1.4;
text-wrap: pretty;
}
.cf-deadline-banner__reassure svg { width: 1em; height: 1em; flex: none; stroke-width: 2.4; }
@keyframes cf-dl-tick { from { opacity: 0.3; transform: translateY(-30%); } to { opacity: 1; transform: none; } }
@keyframes cf-dl-spin { to { transform: rotate(360deg); } }
@media (min-width: 760px) {
.cf-deadline-banner__board {
grid-template-columns: minmax(0, 1.35fr) 1px minmax(0, 1fr);
align-items: center;
gap: clamp(1.25rem, 3vw, 2.25rem);
}
.cf-deadline-banner__divider { width: 1px; height: auto; align-self: stretch; }
}
@media (max-width: 520px) {
.cf-deadline-banner { padding: 1.75rem 1rem; }
.cf-deadline-banner__board { padding: 1.25rem 0.5rem; }
.cf-deadline-banner__clock { gap: 0.3rem; }
.cf-deadline-banner__tile { min-width: 3.9rem; padding: 0.6rem 0.45rem 0.55rem; }
.cf-deadline-banner__digits { font-size: 2rem; }
.cf-deadline-banner__colon { padding-top: 0.55rem; font-size: 1.5rem; }
.cf-deadline-banner__unit-label { font-size: 0.875rem; letter-spacing: 0.02em; }
.cf-deadline-banner__btn { padding: 1rem 1.1rem; font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) {
.cf-deadline-banner *, .cf-deadline-banner *::before, .cf-deadline-banner *::after {
animation: none !important;
transition: none !important;
}
.cf-deadline-banner__btn:hover:not(:disabled),
.cf-deadline-banner__btn:active:not(:disabled),
.cf-deadline-banner.is-hover .cf-deadline-banner__btn,
.cf-deadline-banner.is-active .cf-deadline-banner__btn { transform: none; }
}
`
pieces/urgency/deadline-banner/specimen.tsx 29 lines
import * as React from "react"
import { DeadlineBanner } from "../deadline-banner"
import defaults from "../../studio-defaults.json"
export const states = ["default", "hover", "active", "disabled"]
// The brief sets the deadline at midnight, so the specimen counts down to the next local midnight.
// A page always passes its own real deadline; without one the banner renders nothing.
function nextMidnight() {
const d = new Date()
d.setHours(24, 0, 0, 0)
return d.toISOString()
}
export default function DeadlineBannerSpecimen({ state = "default" }: { state?: "default" | "hover" | "active" | "disabled" }) {
const sample = defaults.sample
const [deadline] = React.useState(nextMidnight)
return (
<DeadlineBanner
deadline={deadline}
productName={sample.name}
price={sample.price}
regularPrice={sample.regularPrice}
label={sample.label}
sublabel={sample.sublabel}
state={state}
/>
)
}
| Name | Type | Details |
|---|---|---|
deadline OptionalDeadlineBanner |
string | number | Date |
|
windowHours OptionalDeadlineBanner |
number |
|
headline OptionalDeadlineBanner |
React.ReactNode |
|
expiredHeadline OptionalDeadlineBanner |
React.ReactNode |
|
lead OptionalDeadlineBanner |
string |
|
expiredLead OptionalDeadlineBanner |
string |
|
productName OptionalDeadlineBanner |
string |
|
price OptionalDeadlineBanner |
string |
|
regularPrice OptionalDeadlineBanner |
string |
|
regularLabel OptionalDeadlineBanner |
string |
|
savingsTemplate OptionalDeadlineBanner |
string |
|
currentLabel OptionalDeadlineBanner |
string |
|
timerLabel OptionalDeadlineBanner |
string |
|
timerSuffix OptionalDeadlineBanner |
string |
|
expiredTimerLabel OptionalDeadlineBanner |
string |
|
units OptionalDeadlineBanner |
{ days: string; hours: string; minutes: string; seconds: string } |
|
label OptionalDeadlineBanner |
string |
|
expiredLabel OptionalDeadlineBanner |
string |
|
loadingLabel OptionalDeadlineBanner |
string |
|
sublabel OptionalDeadlineBanner |
string |
|
href OptionalDeadlineBanner |
string |
|
onAction OptionalDeadlineBanner |
() => void |
|
disabled OptionalDeadlineBanner |
boolean |
|
loading OptionalDeadlineBanner |
boolean |
|
state OptionalDeadlineBanner |
"default" | "hover" | "active" | "disabled" |
|
className OptionalDeadlineBanner |
string |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field-focus- Form inputs: background, ink, border, radius and focus colour.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB