Donation Picker 1
Donation staircase: preset gifts rise left to right with what each one does, the stairs light up to the
Use it in a prompt
Use offer/donation-picker 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/offer/donation-picker.tsx. - Import it and pass your copy and images (Props tab):
import { DonationPicker } from "@/components/funneldna/offer/donation-picker"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/donation-picker/component.tsx 675 lines
// layout: price-staircase
// Donation staircase: preset gifts rise left to right with what each one does, the stairs light up to the
// visitor's gift (preset or typed), and one outcome-worded button hands the validated gift to the page's checkout.
import * as React from "react";
import { AlertCircle, Check, Heart, Lock } from "lucide-react";
export type DonationFrequency = "once" | "monthly";
export type DonationTier = {
/** One-time amount as a plain number in the page currency */
amount: number;
/** What the gift does, written to follow the amount: "feeds a family for a week" */
impact: string;
/** Monthly amount, when it differs from the one-time amount */
monthlyAmount?: number;
/** What the monthly gift does */
monthlyImpact?: string;
/** Button label when this step is chosen, worded as the outcome */
action?: string;
/** Button label for the monthly version of this step */
monthlyAction?: string;
};
export type DonationValues = {
amount: number;
frequency: DonationFrequency;
/** Index of the chosen preset, or null for a typed amount */
tier: number | null;
dedication: { kind: "honor" | "memory"; name: string } | null;
};
export type DonationPickerCopy = {
frequencyLabel: string;
once: string;
monthly: string;
amountsLabel: string;
perMonth: string;
youAreHere: string;
customLabel: string;
customPlaceholder: string;
/** Placeholder: {amount} */
customAction: string;
/** Placeholder: {amount} */
customMonthlyAction: string;
chooseAction: string;
/** Placeholders: {tier}, {impact} */
customCovers: string;
/** Placeholder: {tier} */
customBelow: string;
customEmpty: string;
summaryOnce: string;
summaryMonthly: string;
dedicate: string;
dedicationKindLabel: string;
honor: string;
memory: string;
honoreeLabel: string;
honoreePlaceholder: string;
/** Placeholder: {min} */
errorAmount: string;
errorHonoree: string;
};
export type DonationPickerProps = {
headline?: React.ReactNode;
/** Short paragraphs, each opening with a bold lead-in phrase */
paragraphs?: { lead: React.ReactNode; text: React.ReactNode }[];
/** scene slot: a photo of the work the gift pays for */
image?: string;
imageAlt?: string;
imageCaption?: React.ReactNode;
/** Preset gifts, lowest first */
tiers?: DonationTier[];
defaultTier?: number;
defaultFrequency?: DonationFrequency;
currency?: string;
minAmount?: number;
/** Line beside the one-time / monthly switch */
monthlyNudge?: React.ReactNode;
/** Reassurance line under the button */
note?: React.ReactNode;
copy?: Partial<DonationPickerCopy>;
state?: "default" | "hover" | "active" | "disabled" | "error";
disabled?: boolean;
/** Receives the validated gift; the page wires checkout */
onSubmit?: (values: DonationValues) => void;
className?: string;
};
export function DonationPicker(props: DonationPickerProps) {
const {
headline = "Choose how far your gift goes",
paragraphs = DEFAULT_PARAGRAPHS,
image,
imageAlt = "",
imageCaption,
tiers = DEFAULT_TIERS,
defaultTier = 1,
defaultFrequency = "once",
currency = "$",
minAmount = 5,
monthlyNudge,
note,
copy: copyProp,
state = "default",
disabled = false,
onSubmit,
className,
} = props;
const copy: DonationPickerCopy = { ...DEFAULT_COPY, ...copyProp };
const uid = React.useId();
const startTier = tiers.length ? Math.min(Math.max(0, defaultTier), tiers.length - 1) : null;
const minLabel = money(minAmount, currency);
const errorStart = state === "error";
const [frequency, setFrequency] = React.useState<DonationFrequency>(defaultFrequency);
const [tierIdx, setTierIdx] = React.useState<number | null>(errorStart ? null : startTier);
const [custom, setCustom] = React.useState(errorStart ? ERROR_SAMPLE : "");
const [dedicate, setDedicate] = React.useState(false);
const [kind, setKind] = React.useState<"honor" | "memory">("honor");
const [honoree, setHonoree] = React.useState("");
const [errors, setErrors] = React.useState<FieldErrors>(
errorStart ? { amount: fill(copy.errorAmount, { min: minLabel }) } : {}
);
const customRef = React.useRef<HTMLInputElement>(null);
const honoreeRef = React.useRef<HTMLInputElement>(null);
const firstRun = React.useRef(true);
React.useEffect(() => {
if (firstRun.current) {
firstRun.current = false;
return;
}
if (state === "error") {
setTierIdx(null);
setCustom(ERROR_SAMPLE);
setErrors({ amount: fill(copy.errorAmount, { min: minLabel }) });
} else {
setTierIdx(startTier);
setCustom("");
setErrors({});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);
const isDisabled = disabled || state === "disabled";
const monthly = frequency === "monthly";
const amountOf = (t: DonationTier) => (monthly ? t.monthlyAmount ?? t.amount : t.amount);
const impactOf = (t: DonationTier) => (monthly ? t.monthlyImpact ?? t.impact : t.impact);
const tier = tierIdx === null ? undefined : tiers[tierIdx];
const typed = custom === "" ? NaN : Number.parseFloat(custom);
const amount = tier ? amountOf(tier) : typed;
const hasAmount = Number.isFinite(amount) && amount > 0;
const amountLabel = hasAmount ? money(amount, currency) : "";
let covers = -1;
if (hasAmount) {
tiers.forEach((t, i) => {
if (amount >= amountOf(t)) covers = i;
});
}
const customTemplate = monthly ? copy.customMonthlyAction : copy.customAction;
const action = tier
? (monthly ? tier.monthlyAction ?? tier.action : tier.action) ?? fill(customTemplate, { amount: amountLabel })
: hasAmount
? fill(customTemplate, { amount: amountLabel })
: copy.chooseAction;
let sentence = "";
if (tier) sentence = sentenceCase(impactOf(tier));
else if (!hasAmount) sentence = copy.customEmpty;
else if (covers >= 0)
sentence = fill(copy.customCovers, {
tier: money(amountOf(tiers[covers]), currency),
impact: trimStop(impactOf(tiers[covers])),
});
else if (tiers.length) sentence = fill(copy.customBelow, { tier: money(amountOf(tiers[0]), currency) });
function pickTier(i: number) {
setTierIdx(i);
setCustom("");
setErrors((e) => ({ ...e, amount: undefined }));
}
function typeCustom(value: string) {
const [whole, frac] = value.replace(/[^0-9.]/g, "").split(".");
const clean = (frac === undefined ? whole : `${whole}.${frac.slice(0, 2)}`).slice(0, 9);
setCustom(clean);
if (clean !== "") setTierIdx(null);
setErrors((e) => ({ ...e, amount: undefined }));
}
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
if (isDisabled) return;
const next: FieldErrors = {};
if (!hasAmount || amount < minAmount) next.amount = fill(copy.errorAmount, { min: minLabel });
if (dedicate && !honoree.trim()) next.honoree = copy.errorHonoree;
setErrors(next);
if (next.amount) {
customRef.current?.focus();
return;
}
if (next.honoree) {
honoreeRef.current?.focus();
return;
}
onSubmit?.({
amount,
frequency,
tier: tierIdx,
dedication: dedicate ? { kind, name: honoree.trim() } : null,
});
}
return (
<section className={cx("cf-donation-picker", className)} aria-labelledby={`${uid}-h`}>
<style>{CSS}</style>
<div className="cf-dp-stage">
<div className={cx("cf-dp-wrap", "cf-dp-head", image ? "has-image" : undefined)}>
<div className="cf-dp-intro">
<h2 id={`${uid}-h`} className="cf-dp-h2 cf-dp-in">
{headline}
</h2>
{paragraphs.length > 0 && (
<div className="cf-dp-leadins">
{paragraphs.map((p, i) => (
<p key={i} className="cf-dp-in" style={delay(i + 1)}>
<strong>{p.lead}</strong> {p.text}
</p>
))}
</div>
)}
</div>
{image && (
<figure className="cf-dp-figure cf-dp-in" style={delay(2)}>
<img src={image} alt={imageAlt} width={1200} height={900} loading="lazy" decoding="async" />
{imageCaption && <figcaption>{imageCaption}</figcaption>}
</figure>
)}
</div>
</div>
<div className="cf-dp-wrap">
<form className="cf-dp-console" onSubmit={handleSubmit} noValidate>
<fieldset className="cf-dp-fs" disabled={isDisabled}>
<div className="cf-dp-top">
<div className="cf-dp-toggle" role="radiogroup" aria-label={copy.frequencyLabel}>
{FREQUENCIES.map((f) => (
<label key={f} className="cf-dp-seg" data-on={frequency === f ? "" : undefined}>
<input
className="cf-dp-sr"
type="radio"
name={`${uid}-freq`}
value={f}
checked={frequency === f}
onChange={() => setFrequency(f)}
/>
{f === "monthly" && <Heart size={16} strokeWidth={2.5} aria-hidden="true" />}
<span>{f === "monthly" ? copy.monthly : copy.once}</span>
</label>
))}
</div>
{monthlyNudge && <p className="cf-dp-nudge">{monthlyNudge}</p>}
</div>
<div
className="cf-dp-stairs"
role="radiogroup"
aria-label={copy.amountsLabel}
style={{ "--n": tiers.length } as React.CSSProperties}
>
{tiers.map((t, i) => {
const value = amountOf(t);
const selected = tierIdx === i;
const climbed = hasAmount && amount >= value;
return (
<label
key={i}
className="cf-dp-step"
data-selected={selected ? "" : undefined}
data-climbed={climbed ? "" : undefined}
style={{ "--i": i } as React.CSSProperties}
>
<input
className="cf-dp-sr"
type="radio"
name={`${uid}-amount`}
value={String(value)}
checked={selected}
onChange={() => pickTier(i)}
/>
<span className="cf-dp-step-body">
<span className="cf-dp-step-amount">
<span className="cf-dp-num">{money(value, currency)}</span>
{monthly && <span className="cf-dp-per">{copy.perMonth}</span>}
</span>
<span className="cf-dp-step-impact">{sentenceCase(impactOf(t))}</span>
</span>
<span className="cf-dp-riser" aria-hidden="true">
<span className="cf-dp-riser-tag">
<Heart size={16} strokeWidth={2.5} fill="currentColor" />
{copy.youAreHere}
</span>
</span>
</label>
);
})}
</div>
<div className="cf-dp-bottom">
<div className="cf-dp-options">
<label className="cf-dp-label" htmlFor={`${uid}-custom`}>
{copy.customLabel}
</label>
<div
className="cf-dp-money"
data-active={!tier && custom !== "" ? "" : undefined}
data-invalid={errors.amount ? "" : undefined}
>
<span className="cf-dp-cur" aria-hidden="true">
{currency}
</span>
<input
ref={customRef}
id={`${uid}-custom`}
type="text"
inputMode="decimal"
autoComplete="off"
placeholder={copy.customPlaceholder}
value={custom}
onChange={(e) => typeCustom(e.target.value)}
aria-invalid={errors.amount ? true : undefined}
aria-describedby={errors.amount ? `${uid}-custom-err` : undefined}
/>
{monthly && (
<span className="cf-dp-suffix" aria-hidden="true">
{copy.perMonth}
</span>
)}
</div>
{errors.amount && (
<p className="cf-dp-error" id={`${uid}-custom-err`} role="alert">
<AlertCircle size={16} strokeWidth={2.5} aria-hidden="true" />
{errors.amount}
</p>
)}
<div className="cf-dp-dedicate">
<label className="cf-dp-check">
<span className="cf-dp-box">
<input
type="checkbox"
checked={dedicate}
onChange={(e) => {
setDedicate(e.target.checked);
if (!e.target.checked) setErrors((x) => ({ ...x, honoree: undefined }));
}}
/>
<Check size={16} strokeWidth={3} aria-hidden="true" />
</span>
<span>{copy.dedicate}</span>
</label>
{dedicate && (
<div className="cf-dp-dedication">
<div className="cf-dp-chips" role="radiogroup" aria-label={copy.dedicationKindLabel}>
{KINDS.map((k) => (
<label key={k} className="cf-dp-chip" data-on={kind === k ? "" : undefined}>
<input
className="cf-dp-sr"
type="radio"
name={`${uid}-kind`}
value={k}
checked={kind === k}
onChange={() => setKind(k)}
/>
{k === "memory" ? copy.memory : copy.honor}
</label>
))}
</div>
<label className="cf-dp-label" htmlFor={`${uid}-name`}>
{copy.honoreeLabel}
</label>
<input
ref={honoreeRef}
id={`${uid}-name`}
className="cf-dp-input"
type="text"
autoComplete="off"
placeholder={copy.honoreePlaceholder}
value={honoree}
onChange={(e) => {
setHonoree(e.target.value);
setErrors((x) => ({ ...x, honoree: undefined }));
}}
aria-invalid={errors.honoree ? true : undefined}
aria-describedby={errors.honoree ? `${uid}-name-err` : undefined}
/>
{errors.honoree && (
<p className="cf-dp-error" id={`${uid}-name-err`} role="alert">
<AlertCircle size={16} strokeWidth={2.5} aria-hidden="true" />
{errors.honoree}
</p>
)}
</div>
)}
</div>
</div>
<div className="cf-dp-close">
<div className="cf-dp-summary" aria-live="polite">
{hasAmount && (
<p key={`${amountLabel}-${frequency}`} className="cf-dp-total">
<span className="cf-dp-num">{amountLabel}</span>
<span className="cf-dp-freq">{monthly ? copy.summaryMonthly : copy.summaryOnce}</span>
</p>
)}
{sentence && <p className="cf-dp-impact">{sentence}</p>}
</div>
<button
type="submit"
className={cx(
"cf-dp-btn",
state === "hover" ? "is-hover" : undefined,
state === "active" ? "is-active" : undefined
)}
>
{action}
</button>
{note && (
<p className="cf-dp-note">
<Lock size={16} strokeWidth={2.5} aria-hidden="true" />
{note}
</p>
)}
</div>
</div>
</fieldset>
</form>
</div>
</section>
);
}
export default DonationPicker;
type FieldErrors = { amount?: string; honoree?: string };
const ERROR_SAMPLE = "2";
const FREQUENCIES: DonationFrequency[] = ["once", "monthly"];
const KINDS: ("honor" | "memory")[] = ["honor", "memory"];
const DEFAULT_PARAGRAPHS: { lead: React.ReactNode; text: React.ReactNode }[] = [
{ lead: "Pick a step.", text: "Each amount shows exactly what it does, so you know where your gift lands." },
{ lead: "Make it monthly.", text: "Switch to monthly and your help arrives every month, not just once." },
{ lead: "Make it personal.", text: "Dedicate your gift to someone you love and give in their name." },
];
const DEFAULT_TIERS: DonationTier[] = [
{
amount: 25,
impact: "packs a weekend meal bag for a child",
monthlyImpact: "packs a weekend meal bag every month",
action: "Pack a weekend meal bag",
monthlyAction: "Pack meal bags monthly",
},
{
amount: 50,
impact: "feeds a family for a week",
monthlyImpact: "feeds a family one week of every month",
action: "Feed a family this week",
monthlyAction: "Feed a family every month",
},
{
amount: 100,
impact: "brings fresh produce to four families",
monthlyImpact: "brings fresh produce to four families every month",
action: "Feed four families",
monthlyAction: "Feed four families monthly",
},
{
amount: 250,
impact: "keeps a delivery van on its route for a day",
monthlyImpact: "keeps a delivery van running one day every month",
action: "Fund a full delivery day",
monthlyAction: "Fund a delivery day monthly",
},
];
const DEFAULT_COPY: DonationPickerCopy = {
frequencyLabel: "How often to give",
once: "One-time",
monthly: "Monthly",
amountsLabel: "Choose your gift",
perMonth: "/mo",
youAreHere: "You're here",
customLabel: "Or give an amount you choose",
customPlaceholder: "75",
customAction: "Give {amount} today",
customMonthlyAction: "Give {amount} every month",
chooseAction: "Choose your gift",
customCovers: "That covers the {tier} step: it {impact}.",
customBelow: "Every dollar counts. {tier} is the first step.",
customEmpty: "Type an amount to see what your gift does.",
summaryOnce: "one time",
summaryMonthly: "every month",
dedicate: "Give this gift in honor or memory of someone",
dedicationKindLabel: "Kind of dedication",
honor: "In honor of",
memory: "In memory of",
honoreeLabel: "Their name",
honoreePlaceholder: "Rosa Martinez",
errorAmount: "Enter {min} or more to give.",
errorHonoree: "Add the name of the person you're honoring.",
};
function cx(...parts: (string | false | null | undefined)[]) {
return parts.filter(Boolean).join(" ");
}
function delay(n: number) {
return { "--d": n } as React.CSSProperties;
}
function money(n: number, currency: string) {
const cents = Math.round(n * 100) % 100 !== 0;
return (
currency +
n.toLocaleString("en-US", { minimumFractionDigits: cents ? 2 : 0, maximumFractionDigits: cents ? 2 : 0 })
);
}
function fill(template: string, values: Record<string, string>) {
return Object.keys(values).reduce((out, key) => out.split("{" + key + "}").join(values[key]), template);
}
function trimStop(text: string) {
const t = text.trim();
return t.endsWith(".") ? t.slice(0, -1) : t;
}
function sentenceCase(text: string) {
const t = trimStop(text);
return t ? t.charAt(0).toUpperCase() + t.slice(1) + "." : "";
}
const CSS = `
.cf-donation-picker{--dp-gutter:clamp(16px,5vw,48px);--dp-rise:28px;--dp-well:color-mix(in oklch,var(--ink) 4%,var(--card));--dp-ring:oklch(from var(--field-focus,var(--accent)) l c h / .35);--dp-shade:var(--shadow,oklch(.22 .03 260));position:relative;background:var(--surface);color:var(--ink);font-family:var(--font-body);padding-bottom:clamp(64px,8.5vw,120px);overflow-x:clip}
.cf-donation-picker *,.cf-donation-picker *::before,.cf-donation-picker *::after{box-sizing:border-box}
.cf-dp-stage{background:var(--band);color:var(--band-ink);padding:clamp(56px,8vw,112px) 0 clamp(112px,13vw,184px)}
.cf-dp-wrap{width:100%;max-width:calc(1120px + 2 * var(--dp-gutter));margin-inline:auto;padding-inline:var(--dp-gutter)}
.cf-dp-head{display:grid;gap:clamp(32px,5vw,72px);align-items:start}
.cf-dp-head.has-image{grid-template-columns:minmax(0,1.05fr) minmax(0,.95fr)}
.cf-dp-intro{min-width:0}
.cf-dp-h2{margin:0 0 20px;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance;color:var(--band-ink)}
.cf-dp-leadins{display:grid;gap:16px}
.cf-dp-leadins p{margin:0;max-width:60ch;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;text-wrap:pretty;color:var(--band-ink)}
.cf-dp-leadins strong{font-family:var(--font-body);font-weight:800;color:var(--band-ink)}
.cf-dp-figure{margin:0;min-width:0}
.cf-dp-figure img{display:block;width:100%;height:auto;aspect-ratio:4/3;object-fit:cover;object-position:center;border-radius:12px;background:oklch(from var(--band-ink) l c h / .08)}
.cf-dp-figure figcaption{margin-top:12px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--band-ink);text-wrap:pretty}
.cf-dp-in{animation:cf-dp-rise .45s cubic-bezier(.2,.7,.2,1) backwards;animation-delay:calc(var(--d,0) * .07s)}
.cf-dp-console{position:relative;margin-top:calc(-1 * clamp(80px,10vw,144px));background:var(--card);color:var(--ink);border:1px solid var(--card-border,oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px oklch(.22 .03 260 / .22),0 12px 24px -8px oklch(.22 .03 260 / .32)));padding:clamp(20px,3vw,32px)}
.cf-dp-fs{border:0;margin:0;padding:0;min-inline-size:0}
.cf-dp-sr{position:absolute;top:0;left:0;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
.cf-dp-top{display:flex;flex-wrap:wrap;align-items:center;gap:12px 24px;margin-bottom:28px}
.cf-dp-toggle{display:inline-grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;background:color-mix(in oklch,var(--ink) 6%,var(--card));border-radius:calc(var(--radius,12px) + 4px)}
.cf-dp-seg{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:0 24px;border:1px solid transparent;border-radius:var(--radius,12px);font-size:1.0625rem;font-weight:700;line-height:1.2;color:var(--ink);white-space:nowrap;cursor:pointer;transition:background-color .16s ease,box-shadow .16s ease,border-color .16s ease}
.cf-dp-seg:hover{border-color:oklch(from var(--ink) l c h / .12)}
.cf-dp-seg[data-on]{background:var(--card);border-color:oklch(from var(--ink) l c h / .16);font-weight:800;box-shadow:var(--shadow-sm,0 1px 1px oklch(.22 .03 260 / .18),0 1px 3px oklch(.22 .03 260 / .14))}
.cf-dp-seg svg{color:var(--accent)}
.cf-dp-seg:has(:focus-visible){outline:3px solid var(--dp-ring);outline-offset:2px}
.cf-dp-nudge{flex:1 1 240px;margin:0;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);text-wrap:pretty}
.cf-dp-stairs{display:grid;grid-template-columns:repeat(var(--n),minmax(0,1fr));gap:16px}
.cf-dp-step{position:relative;display:flex;flex-direction:column;margin-top:calc(var(--dp-rise) * (var(--n) - 1 - var(--i)));background:var(--dp-well);border:1px solid oklch(from var(--ink) l c h / .1);border-radius:var(--radius,12px);overflow:hidden;cursor:pointer;animation:cf-dp-rise .45s cubic-bezier(.2,.7,.2,1) backwards;animation-delay:calc(var(--i) * .07s);transition:transform .16s ease,box-shadow .16s ease,background-color .16s ease,border-color .16s ease}
.cf-dp-step:hover{transform:translateY(-2px);border-color:oklch(from var(--ink) l c h / .24);box-shadow:var(--shadow-sm,0 1px 2px oklch(.22 .03 260 / .2))}
.cf-dp-step:active{transform:translateY(0)}
.cf-dp-step[data-selected]{background:var(--card);border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),var(--shadow-lg,0 2px 4px oklch(.22 .03 260 / .22),0 12px 24px -8px oklch(.22 .03 260 / .32));transform:translateY(-4px)}
.cf-dp-step:has(.cf-dp-sr:focus-visible){outline:3px solid var(--dp-ring);outline-offset:3px}
.cf-dp-step-body{display:block;padding:20px}
.cf-dp-step-amount{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 6px}
.cf-dp-num{font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:-0.03em;line-height:1;font-variant-numeric:tabular-nums}
.cf-dp-step .cf-dp-num{font-size:clamp(2rem,3.6vw,3.25rem);color:var(--ink);transition:color .16s ease}
.cf-dp-step[data-selected] .cf-dp-num{color:var(--accent)}
.cf-dp-per{font-size:.9375rem;font-weight:700;color:var(--muted)}
.cf-dp-step-impact{display:block;margin-top:12px;font-size:1.0625rem;font-weight:500;line-height:1.4;color:var(--ink);text-wrap:pretty}
.cf-dp-riser{position:relative;flex:1 1 auto;min-height:44px;background:oklch(from var(--ink) l c h / .045);overflow:hidden}
.cf-dp-riser::before{content:"";position:absolute;inset:0;background:oklch(from var(--accent-fill,var(--accent)) l c h / .42);transform:scaleY(0);transform-origin:bottom;transition:transform .4s cubic-bezier(.2,.7,.2,1),background-color .2s ease;transition-delay:calc(var(--i) * .07s)}
.cf-dp-step[data-climbed] .cf-dp-riser::before{transform:scaleY(1)}
.cf-dp-step[data-selected] .cf-dp-riser::before{background:var(--accent-fill,var(--accent))}
.cf-dp-riser-tag{position:absolute;left:14px;bottom:12px;display:inline-flex;align-items:center;gap:6px;font-size:.875rem;font-weight:800;line-height:1.2;white-space:nowrap;color:var(--accent-fill-ink,var(--card));opacity:0;transform:translateY(4px);transition:opacity .2s ease,transform .2s ease}
.cf-dp-step[data-selected] .cf-dp-riser-tag{opacity:1;transform:none;transition-delay:.2s}
.cf-dp-fs:disabled .cf-dp-step,.cf-dp-fs:disabled .cf-dp-seg,.cf-dp-fs:disabled .cf-dp-check,.cf-dp-fs:disabled .cf-dp-chip{cursor:not-allowed}
.cf-dp-fs:disabled .cf-dp-step:hover{transform:none;box-shadow:none;border-color:oklch(from var(--ink) l c h / .1)}
.cf-dp-fs:disabled .cf-dp-step[data-selected]{transform:none;border-color:oklch(from var(--ink) l c h / .22);box-shadow:0 0 0 1px oklch(from var(--ink) l c h / .22)}
.cf-dp-fs:disabled .cf-dp-step[data-selected] .cf-dp-num{color:var(--ink)}
.cf-dp-fs:disabled .cf-dp-riser::before{background:oklch(from var(--ink) l c h / .16)}
.cf-dp-fs:disabled .cf-dp-riser-tag{color:var(--ink)}
.cf-dp-fs:disabled .cf-dp-money,.cf-dp-fs:disabled .cf-dp-money input{background:color-mix(in oklch,var(--ink) 5%,var(--field))}
.cf-dp-bottom{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:clamp(32px,5vw,64px);align-items:start;margin-top:40px}
.cf-dp-options,.cf-dp-close{min-width:0}
.cf-dp-label{display:block;margin-bottom:8px;font-size:1.0625rem;font-weight:700;line-height:1.3;color:var(--label-ink,var(--ink))}
.cf-dp-money{display:flex;align-items:center;min-height:56px;overflow:hidden;background:var(--field);color:var(--field-ink);border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));transition:border-color .16s ease,box-shadow .16s ease}
.cf-dp-money[data-active]{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.cf-dp-money:focus-within{border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 3px var(--dp-ring)}
.cf-dp-money[data-invalid]{border-color:var(--danger);box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .22)}
.cf-dp-cur,.cf-dp-suffix{flex:none;font-family:var(--font-display);font-weight:800;color:var(--field-ink)}
.cf-dp-cur{padding-left:18px;font-size:1.375rem}
.cf-dp-suffix{padding-right:18px;font-size:1.0625rem}
.cf-dp-money input{flex:1 1 auto;min-width:0;height:54px;margin:0;padding:0 18px 0 8px;border:0;outline:0;background:var(--field);color:var(--field-ink);font-family:var(--font-display);font-weight:800;font-size:1.375rem;font-variant-numeric:tabular-nums}
.cf-donation-picker input::placeholder{color:color-mix(in oklch,var(--field-ink) 65%,var(--field));opacity:1;font-weight:500}
.cf-dp-input{display:block;width:100%;height:56px;margin:0;padding:0 18px;background:var(--field);color:var(--field-ink);border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));font-family:var(--font-body);font-size:1.0625rem;transition:border-color .16s ease,box-shadow .16s ease}
.cf-dp-input:focus{outline:0;border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 3px var(--dp-ring)}
.cf-dp-input[aria-invalid="true"]{border-color:var(--danger);box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .22)}
.cf-dp-error{margin:8px 0 0;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--danger);text-wrap:pretty}
.cf-dp-error svg,.cf-dp-note svg{display:inline-block;vertical-align:-.15em;margin-inline-end:.4em}
.cf-dp-dedicate{margin-top:24px}
.cf-dp-check{display:flex;align-items:flex-start;gap:12px;font-size:1.0625rem;font-weight:600;line-height:1.4;color:var(--ink);cursor:pointer;text-wrap:pretty}
.cf-dp-box{position:relative;flex:none;display:grid;place-items:center;width:26px;height:26px;margin-top:-1px}
.cf-dp-box input{appearance:none;-webkit-appearance:none;position:absolute;inset:0;width:100%;height:100%;margin:0;border:2px solid color-mix(in oklch,var(--ink) 45%,var(--card));border-radius:7px;background:var(--field);cursor:inherit;transition:background-color .16s ease,border-color .16s ease}
.cf-dp-box svg{position:relative;color:var(--accent-fill-ink,var(--card));opacity:0;transform:scale(.9);transition:opacity .16s ease,transform .16s ease;pointer-events:none}
.cf-dp-box input:checked{background:var(--accent-fill,var(--accent));border-color:var(--accent-fill,var(--accent))}
.cf-dp-box input:checked + svg{opacity:1;transform:none}
.cf-dp-box input:focus-visible{outline:3px solid var(--dp-ring);outline-offset:2px}
.cf-dp-check:hover .cf-dp-box input:not(:checked){border-color:var(--accent)}
.cf-dp-dedication{margin-top:16px;padding:20px;background:var(--dp-well);border-radius:10px;animation:cf-dp-rise .45s cubic-bezier(.2,.7,.2,1) backwards}
.cf-dp-chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:16px}
.cf-dp-chip{position:relative;display:inline-flex;align-items:center;min-height:44px;padding:0 18px;border-radius:999px;background:var(--card);color:var(--ink);border:1px solid oklch(from var(--ink) l c h / .16);font-size:.9375rem;font-weight:700;line-height:1.2;cursor:pointer;transition:border-color .16s ease,background-color .16s ease}
.cf-dp-chip:hover{border-color:oklch(from var(--ink) l c h / .32)}
.cf-dp-chip[data-on]{background:color-mix(in oklab,var(--accent) 10%,var(--card));border-color:var(--accent);font-weight:800}
.cf-dp-chip:has(:focus-visible){outline:3px solid var(--dp-ring);outline-offset:2px}
.cf-dp-summary{margin-bottom:24px}
.cf-dp-total{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin:0 0 12px;animation:cf-dp-rise .3s cubic-bezier(.2,.7,.2,1) backwards}
.cf-dp-total .cf-dp-num{font-size:clamp(2.5rem,4.2vw,3.75rem);color:var(--ink)}
.cf-dp-freq{font-size:clamp(1.125rem,1.5vw,1.375rem);font-weight:700;color:var(--muted)}
.cf-dp-impact{margin:0;font-size:clamp(1.125rem,1.5vw,1.375rem);font-weight:500;line-height:1.4;color:var(--ink);text-wrap:pretty}
.cf-dp-btn{--dp-bb:var(--button-bg,var(--cta));--dp-bb2:var(--button-bg-2,var(--cta-2));appearance:none;display:flex;align-items:center;justify-content:center;width:100%;min-height:64px;margin:0;padding:12px 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from var(--dp-bb) calc(l + .04) c h),oklch(from var(--dp-bb2) calc(l - .02) c h));color:var(--button-ink,var(--cta-ink));font-family:var(--button-font,var(--font-display));font-weight:var(--button-weight,800);text-transform:var(--button-case,none);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-align:center;text-wrap:balance;text-shadow:var(--button-text-shadow,none);cursor:pointer;box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--dp-bb) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--dp-bb) calc(l - .16) c h),0 1px 2px oklch(from var(--dp-shade) l c h / .3),0 8px 16px -6px oklch(from var(--dp-shade) l c h / .42));transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
.cf-dp-btn:hover,.cf-dp-btn.is-hover{transform:translateY(-1px);background:linear-gradient(oklch(from var(--dp-bb) calc(l - .01) c h),oklch(from var(--dp-bb2) calc(l - .07) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--dp-bb) calc(l + .12) c h / .6),inset 0 -3px 0 oklch(from var(--dp-bb) calc(l - .2) c h),0 1px 2px oklch(from var(--dp-shade) l c h / .34),0 10px 18px -6px oklch(from var(--dp-shade) l c h / .5))}
.cf-dp-btn:active,.cf-dp-btn.is-active{transform:translateY(1px);background:linear-gradient(oklch(from var(--dp-bb) calc(l - .04) c h),oklch(from var(--dp-bb2) calc(l - .08) c h));box-shadow:inset 0 2px 4px oklch(from var(--dp-bb) calc(l - .22) c h / .55),inset 0 -2px 0 oklch(from var(--dp-bb) calc(l - .16) c h),0 1px 2px oklch(from var(--dp-shade) l c h / .3)}
.cf-dp-btn:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-dp-btn:disabled{cursor:not-allowed;transform:none;background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));text-shadow:none;box-shadow:none}
.cf-dp-note{margin:12px 0 0;text-align:center;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);text-wrap:pretty}
@media (hover:hover) and (min-width:1000px){
.cf-dp-fs:not(:disabled) .cf-dp-step:not([data-climbed]):hover .cf-dp-riser::before{transform:scaleY(.22);transition-delay:0s}
}
@media (max-width:999px){
.cf-dp-stairs{grid-template-columns:minmax(0,1fr);gap:12px}
.cf-dp-step{margin-top:0}
.cf-dp-step[data-selected]{transform:translateY(-2px)}
.cf-dp-step-body{flex:none;min-width:0;padding:16px 18px 12px}
.cf-dp-riser{flex:none;min-height:0;height:6px;margin:0 18px 16px;border-radius:999px;background:oklch(from var(--ink) l c h / .08)}
.cf-dp-riser::before{right:auto;width:calc((var(--i) + 1) / var(--n) * 100%);border-radius:inherit;transform:scaleX(0);transform-origin:left}
.cf-dp-step[data-climbed] .cf-dp-riser::before{transform:scaleX(1)}
.cf-dp-riser-tag{display:none}
}
@media (min-width:560px) and (max-width:999px){
.cf-dp-step-body{display:grid;grid-template-columns:minmax(120px,max-content) minmax(0,1fr);align-items:center;column-gap:24px}
.cf-dp-step-impact{margin-top:0}
}
@media (max-width:860px){
.cf-dp-head.has-image{grid-template-columns:minmax(0,1fr)}
.cf-dp-figure img{aspect-ratio:16/10}
.cf-dp-bottom{grid-template-columns:minmax(0,1fr);gap:32px;margin-top:32px}
}
@media (max-width:520px){
.cf-dp-toggle{display:grid;width:100%}
.cf-dp-seg{padding:0 12px}
.cf-dp-btn{padding:12px 16px;font-size:1.125rem}
}
@keyframes cf-dp-rise{from{opacity:.82;transform:translateY(8px)}}
@media (prefers-reduced-motion:reduce){
.cf-donation-picker *,.cf-donation-picker *::before,.cf-donation-picker *::after{animation:none !important;transition:none !important}
}
`;
pieces/offer/donation-picker/specimen.tsx 30 lines
import __studioImagef7071d64 from "../assets/473524395833a104.webp";
// Specimen: the donation staircase for a fictional community food bank, with a generated scene photo.
import { DonationPicker } from "../donation-picker";
import { slot } from "../../slots";
export const states = ["default", "hover", "active", "disabled", "error"];
type SpecimenState = "default" | "hover" | "active" | "disabled" | "error";
export default function DonationPickerSpecimen({ state = "default" }: { state?: SpecimenState }) {
return (
<DonationPicker
state={state}
headline="Every step up puts dinner on another family's table"
paragraphs={[
{ lead: "Pick a step.", text: "Each amount shows exactly what it does, so you know where your gift lands." },
{ lead: "Go monthly.", text: "Monthly gifts let our drivers plan deliveries months ahead, not week to week." },
{ lead: "Make it personal.", text: "Dedicate your gift to someone you love and give in their name." },
]}
image={slot(
"scene",
__studioImagef7071d64
)}
imageAlt="A volunteer hands a box of fresh groceries to a parent and child at a community food bank"
imageCaption="Your gift packs boxes like this one for families across town."
monthlyNudge="Monthly gifts keep the shelves stocked all year."
note="Secure donation · Receipt sent to your email"
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalDonationPicker |
React.ReactNode |
|
paragraphs OptionalDonationPicker |
{ lead: React.ReactNode; text: React.ReactNode }[] |
|
image OptionalDonationPicker |
string |
|
imageAlt OptionalDonationPicker |
string |
|
imageCaption OptionalDonationPicker |
React.ReactNode |
|
tiers OptionalDonationPicker |
DonationTier[] |
|
defaultTier OptionalDonationPicker |
number |
|
defaultFrequency OptionalDonationPicker |
DonationFrequency |
|
currency OptionalDonationPicker |
string |
|
minAmount OptionalDonationPicker |
number |
|
monthlyNudge OptionalDonationPicker |
React.ReactNode |
|
note OptionalDonationPicker |
React.ReactNode |
|
copy OptionalDonationPicker |
Partial<DonationPickerCopy> |
|
state OptionalDonationPicker |
"default" | "hover" | "active" | "disabled" | "error" |
|
disabled OptionalDonationPicker |
boolean |
|
onSubmit OptionalDonationPicker |
(values: DonationValues) => void |
|
className OptionalDonationPicker |
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- 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--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
scene- A wide atmosphere photo behind or beside the copy.
-
473524395833a104.webp
image/webp · 120 KB