Bundle Picker 1
Lets buyers compare package savings and submit their selected quantity.
Use it in a prompt
Use offer/bundle-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/bundle-picker.tsx. - Import it and pass your copy and images (Props tab):
import { BundlePicker } from "@/components/funneldna/offer/bundle-picker"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/bundle-picker/component.tsx 886 lines
// Lets buyers compare package savings and submit their selected quantity.
'use client'
import * as React from 'react'
import { AlertCircle, Award, Check, Loader2, Lock, ShieldCheck, Tag } from 'lucide-react'
import { AmericanExpress, Discover, Mastercard, Visa } from 'react-svg-credit-card-payment-icons/icons/flat-rounded'
export type BundlePackage = {
/** Number of units in the package, e.g. 1, 3, 6. */
units: number
/** Total price of the package, as a number in the chosen currency. */
price: number
/** Product shot for this package (one bottle, three, six). */
image?: string
imageAlt?: string
/** Short factual line under the quantity, e.g. 3-month supply. */
note?: string
/** Value posted for this package; defaults to the unit count. */
id?: string
}
export type BundlePickerState = 'default' | 'hover' | 'active' | 'disabled' | 'loading' | 'error' | 'success'
export type BundleLabelContext = { units: number; unitWord: string; total: string; perUnit: string }
export type BundlePickerProps = {
headline?: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
lead?: string
packages?: BundlePackage[]
unit?: { one: string; other: string }
/** Index selected on load; defaults to the best-value package. */
defaultSelected?: number
currency?: string
locale?: string
buttonLabel?: (ctx: BundleLabelContext) => string
loadingLabel?: string
bestValueLabel?: string
secureLabel?: string
guarantee?: string
showPaymentMarks?: boolean
errorMessage?: string
/** Deprecated: ignored. The builder wires what happens after the action. */
successTitle?: (ctx: BundleLabelContext) => string
/** Deprecated: ignored. The builder wires what happens after the action. */
successBody?: string
/** Deprecated: ignored. The builder wires what happens after the action. */
changeLabel?: string
/** "success" is accepted for older callers and renders as default. */
state?: BundlePickerState
onSelect?: (pkg: BundlePackage, index: number) => void
/** Called on submit with the selected package. Without it the button does nothing visible. */
onSubmit?: (pkg: BundlePackage, index: number) => void | Promise<void>
/** Templates accept {units}, {unit}, {savings}, {percent}, {total}, and {perUnit}. */
copy?: Partial<BundlePickerCopy>
paymentLabels?: Partial<Record<'Visa' | 'Mastercard' | 'American Express' | 'Discover', string>>
className?: string
style?: React.CSSProperties
}
export function BundlePicker({
headline = 'The more you stock up, the less you pay',
highlight = 'the less you pay',
lead,
packages = DEFAULT_PACKAGES,
unit = { one: 'Bottle', other: 'Bottles' },
defaultSelected,
currency = 'USD',
locale = 'en-US',
buttonLabel = ({ units, unitWord }) => `Yes! Send Me ${units} ${unitWord}`,
loadingLabel = 'Adding to your order…',
bestValueLabel = 'Best value',
secureLabel = '',
guarantee = '30-day money-back guarantee',
showPaymentMarks = true,
errorMessage = 'We couldn’t add that to your order. Please try again.',
state,
onSelect,
onSubmit,
copy,
paymentLabels,
className,
style,
}: BundlePickerProps) {
const text = { perUnit: 'per {unit}', regularPrice: '{units} at the single {unit} price: ', total: ' total', savings: 'You save {savings} ({percent}%)', singlePrice: 'Single-{unit} price', successSummary: '{total} total · {perUnit} per {unit}', selected: 'You picked', unitSummary: '({perUnit} per {unit})', selectedSavings: 'You save {savings}', payments: 'Accepted payment methods', ...copy }
const uid = React.useId()
const titleId = `${uid}-title`
const groupName = `${uid}-package`
const money = React.useCallback(
(n: number) => {
const whole = Math.abs(n - Math.round(n)) < 0.005
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
minimumFractionDigits: whole ? 0 : 2,
maximumFractionDigits: whole ? 0 : 2,
}).format(whole ? Math.round(n) : n)
},
[locale, currency]
)
const rows = React.useMemo(() => {
const valid = packages.filter((p) => p.units > 0)
const base = valid.reduce((m, p) => (p.units < m.units ? p : m), valid[0] ?? packages[0])
const baseUnit = base && base.units > 0 ? base.price / base.units : 0
return packages.map((p) => {
const perUnit = p.units > 0 ? p.price / p.units : p.price
const compare = baseUnit * p.units
const raw = compare - p.price
const savings = raw > 0.005 ? raw : 0
const pct = savings > 0 && compare > 0 ? Math.round((savings / compare) * 100) : 0
return { perUnit, compare, savings, pct, baseUnit, isBase: p === base }
})
}, [packages])
const bestIndex = React.useMemo(() => {
if (rows.length < 2) return -1
const min = Math.min(...rows.map((r) => r.perUnit))
const hits = rows.filter((r) => Math.abs(r.perUnit - min) < 0.005)
if (hits.length !== 1 || min >= rows[0].baseUnit - 0.005) return -1
return rows.findIndex((r) => Math.abs(r.perUnit - min) < 0.005)
}, [rows])
const [selected, setSelected] = React.useState(() => {
if (typeof defaultSelected === 'number' && defaultSelected >= 0 && defaultSelected < packages.length) return defaultSelected
return bestIndex >= 0 ? bestIndex : 0
})
const [status, setStatus] = React.useState<Status>(() => statusFrom(state))
React.useEffect(() => {
setStatus(statusFrom(state))
}, [state])
const alive = React.useRef(true)
React.useEffect(() => {
alive.current = true
return () => {
alive.current = false
}
}, [])
const disabled = state === 'disabled'
const loading = status === 'loading'
const forced = state === 'hover' || state === 'active' ? state : undefined
const index = Math.min(Math.max(selected, 0), Math.max(packages.length - 1, 0))
const pkg = packages[index]
const row = rows[index]
const wordFor = (n: number) => (n === 1 ? unit.one : unit.other)
const perWord = unit.one.toLowerCase()
const choose = (i: number) => {
if (disabled || loading) return
setSelected(i)
if (status === 'error') setStatus('idle')
onSelect?.(packages[i], i)
}
const submit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (disabled || loading || !pkg || !onSubmit) return
setStatus('loading')
try {
await onSubmit(pkg, index)
if (alive.current) setStatus('idle')
} catch {
if (alive.current) setStatus('error')
}
}
if (!pkg || !row) return null
const ctx: BundleLabelContext = {
units: pkg.units,
unitWord: wordFor(pkg.units),
total: money(pkg.price),
perUnit: money(row.perUnit),
}
return (
<form
className={['cfbp cf-bundle-picker', className].filter(Boolean).join(' ')}
style={style}
onSubmit={submit}
noValidate
data-state={state ?? 'default'}
>
<style>{CSS}</style>
<header className='bp-head'>
<h2 id={titleId} className='bp-title'>
{withMarker(headline, highlight)}
</h2>
{lead ? <p className='bp-lead'>{lead}</p> : null}
</header>
<div
className='bp-grid'
role='radiogroup'
aria-labelledby={titleId}
style={{ '--bp-cols': Math.min(packages.length, 3) } as React.CSSProperties}
>
{packages.map((p, i) => {
const r = rows[i]
const isSel = i === index
const isBest = i === bestIndex
const word = wordFor(p.units)
return (
<label
key={p.id ?? `${p.units}-${i}`}
className='bp-card'
data-selected={isSel ? '' : undefined}
data-best={isBest ? '' : undefined}
data-disabled={disabled ? '' : undefined}
style={{ '--i': i } as React.CSSProperties}
>
<input
className='bp-input'
type='radio'
name={groupName}
value={p.id ?? String(p.units)}
checked={isSel}
disabled={disabled || loading}
onChange={() => choose(i)}
/>
{isBest ? (
<span className='bp-flag'>
<Award aria-hidden='true' />
{bestValueLabel}
</span>
) : null}
<span className='bp-cardhead'>
<span className='bp-radio' aria-hidden='true'>
<Check strokeWidth={3.5} />
</span>
<span className='bp-qty'>
{p.units} {word}
</span>
{p.note ? <span className='bp-note'>{p.note}</span> : null}
</span>
<span className={p.image ? 'bp-body bp-body--media' : 'bp-body'}>
{p.image ? (
<span className='bp-media'>
<img
src={p.image}
alt={p.imageAlt ?? `${p.units} ${word}`}
width={480}
height={480}
loading='lazy'
decoding='async'
/>
</span>
) : null}
<span className='bp-pricing'>
<span className='bp-unit'>
<span className='bp-unit-num'>{money(r.perUnit)}</span>
<span className='bp-unit-per'>{formatCopy(text.perUnit, { unit: perWord })}</span>
</span>
<span className='bp-total'>
{r.savings > 0 ? (
<s>
<span className='bp-sr'>{formatCopy(text.regularPrice, { units: p.units, unit: perWord })}</span>
{money(r.compare)}
</s>
) : null}
<b>{money(p.price)}</b>{text.total}
</span>
{r.savings > 0 ? (
<span className='bp-save'>
<Tag aria-hidden='true' />
{formatCopy(text.savings, { savings: money(r.savings), percent: r.pct })}
</span>
) : r.isBase ? (
<span className='bp-save bp-save--none'>{formatCopy(text.singlePrice, { unit: perWord })}</span>
) : null}
</span>
</span>
</label>
)
})}
</div>
<div className='bp-action'>
{(
<>
<p className='bp-summary' aria-live='polite'>
<span className='bp-summary-inner' key={index}>
<span className='bp-summary-line'>
<span className='bp-summary-lead'>{text.selected}</span>{' '}
<b>
{ctx.units} {ctx.unitWord}
</b>
<span className='bp-sep' aria-hidden='true'>
·
</span>
<b>{ctx.total}</b>{' '}
<span className='bp-summary-unit'>
{formatCopy(text.unitSummary, { perUnit: ctx.perUnit, unit: perWord })}
</span>
</span>
{row.savings > 0 ? (
<span className='bp-summary-save'>
<Tag aria-hidden='true' />
{formatCopy(text.selectedSavings, { savings: money(row.savings) })}
</span>
) : null}
</span>
</p>
{status === 'error' ? (
<p className='bp-error' role='alert'>
<AlertCircle aria-hidden='true' />
<span>{errorMessage}</span>
</p>
) : null}
<button
type='submit'
className='bp-btn'
disabled={disabled}
aria-busy={loading || undefined}
data-force={forced}
>
{loading ? (
<>
<Loader2 className='bp-btn-icon bp-spin' aria-hidden='true' />
<span className='bp-btn-label'>{loadingLabel}</span>
</>
) : (
<>
<span className='bp-btn-label'>{buttonLabel(ctx)}</span>
</>
)}
</button>
{secureLabel || guarantee ? (
<p className='bp-reassure'>
{secureLabel ? (
<span>
<Lock aria-hidden='true' />
{secureLabel}
</span>
) : null}
{guarantee ? (
<span className='bp-reassure-guarantee'>
<ShieldCheck aria-hidden='true' />
{guarantee}
</span>
) : null}
</p>
) : null}
{showPaymentMarks ? (
<ul className='bp-pay' aria-label={text.payments}>
{PAY.map(([label, Mark]) => (
<li key={label}>
<Mark width={40} aria-label={paymentLabels?.[label] ?? label} />
</li>
))}
</ul>
) : null}
</>
)}
</div>
</form>
)
}
export default BundlePicker
type BundlePickerCopy = { perUnit: string; regularPrice: string; total: string; savings: string; singlePrice: string; successSummary: string; selected: string; unitSummary: string; selectedSavings: string; payments: string }
function formatCopy(template: string, values: Record<string, string | number>) {
return template.replace(/\{(\w+)\}/g, (placeholder, key: string) => values[key] === undefined ? placeholder : String(values[key]))
}
type Status = 'idle' | 'loading' | 'error'
const DEFAULT_PACKAGES: BundlePackage[] = [
{ units: 1, price: 47 },
{ units: 3, price: 129 },
{ units: 6, price: 234 },
]
const PAY = [
['Visa', Visa],
['Mastercard', Mastercard],
['American Express', AmericanExpress],
['Discover', Discover],
] as const
function statusFrom(state?: BundlePickerState): Status {
if (state === 'loading' || state === 'error') return state
return 'idle'
}
function withMarker(text: string, phrase?: string) {
if (!phrase) return text
const at = text.indexOf(phrase)
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='bp-mark'>{phrase}</span>
{text.slice(at + phrase.length)}
</>
)
}
// Reduced-motion !important preserves the existing animation and transition cascade.
const CSS = `
.cf-bundle-picker {
--bp-radius: var(--radius, 12px);
--bp-marker: var(--marker, color-mix(in oklch, var(--accent) 12%, var(--card)));
--bp-gold: var(--cta);
--bp-gold-edge: var(--success);
--bp-save-ink: var(--success);
--bp-save-bg: var(--success-soft);
--bp-save-line:var(--success);
--bp-line:oklch(from var(--ink, #101828) l c h / 0.13);
--bp-ease: cubic-bezier(.2, .8, .2, 1);
position: relative;
width: 100%;
max-width: 68rem;
margin: 0 auto;
font-family: var(--font-body, Arial, sans-serif);
color: var(--ink, #101828);
-webkit-font-smoothing: antialiased;
}
.cf-bundle-picker *, .cf-bundle-picker *::before, .cf-bundle-picker *::after { box-sizing: border-box; }
.cf-bundle-picker :where(h2, p, ul) { margin: 0; }
.cf-bundle-picker .bp-sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* heading */
.cf-bundle-picker .bp-head { max-width: 48rem; margin: 0 auto 2.5rem; text-align: center; }
.cf-bundle-picker .bp-title {
margin: 0 auto;
font-family: var(--font-display, Arial, sans-serif);
font-weight: var(--display-weight, 900);
font-size: clamp(2rem, 1.2rem + 3.4vw, 3.375rem);
line-height: 1.05;
letter-spacing: var(--display-tracking, -0.025em);
color: var(--ink, #101828);
text-wrap: balance;
text-transform: var(--display-case, none);
}
.cf-bundle-picker .bp-mark {
padding: 0 .14em;
margin: 0 -.04em;
border-radius: .4em .2em .5em .25em;
background: linear-gradient(177deg, transparent 0 40%, var(--bp-marker) 40% 94%, transparent 94%);
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
.cf-bundle-picker .bp-lead {
margin: 1rem auto 0;
max-width: 44ch;
font-size: clamp(1.0625rem, 1rem + .4vw, 1.25rem);
font-weight: 500;
line-height: 1.5;
color: var(--muted, #4a5565);
text-wrap: pretty;
}
/* package cards */
.cf-bundle-picker .bp-grid {
display: grid;
grid-template-columns: repeat(var(--bp-cols, 3), minmax(0, 1fr));
gap: 1.5rem;
align-items: stretch;
padding-top: 1rem;
}
.cf-bundle-picker .bp-card {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
background: var(--card, #fff);
border: 1px solid var(--card-border, var(--bp-line));
border-radius: var(--card-radius, calc(var(--bp-radius) + 4px));
box-shadow:var(--card-shadow, var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));
cursor: pointer;
transition: transform .22s var(--bp-ease), box-shadow .22s var(--bp-ease), border-color .2s ease;
animation: bp-rise .45s var(--bp-ease) backwards;
animation-delay: calc(var(--i, 0) * 70ms);
}
.cf-bundle-picker .bp-card:hover {
transform: translateY(-3px);
box-shadow:var(--card-shadow, var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));
}
.cf-bundle-picker .bp-card[data-selected] {
border-color: var(--card-border, var(--accent, #0f5fc2));
transform: translateY(-4px);
box-shadow:0 0 0 2px var(--accent, #0f5fc2),0 0 0 7px oklch(from var(--accent, #0f5fc2) l c h / 0.16),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35);
}
.cf-bundle-picker .bp-card:has(.bp-input:focus-visible) { outline: 3px solid var(--ink, #101828); outline-offset: 10px; }
.cf-bundle-picker .bp-card[data-disabled] { cursor: not-allowed; }
.cf-bundle-picker .bp-card[data-disabled]:hover { transform: none; }
.cf-bundle-picker .bp-card[data-disabled][data-selected] { transform: none; }
.cf-bundle-picker .bp-card[data-disabled] .bp-media img { filter: grayscale(.5); opacity: .75; }
.cf-bundle-picker .bp-input {
position: absolute;
width: 1px;
height: 1px;
margin: 0;
opacity: 0;
overflow: hidden;
clip-path: inset(50%);
accent-color: var(--field-focus, var(--accent));
}
.cf-bundle-picker .bp-flag {
position: absolute;
z-index: 3;
top: 0;
left: 50%;
transform: translate(-50%, -50%);
display: inline-flex;
align-items: center;
gap: .4rem;
padding: .4rem .95rem;
border-radius: 999px;
background: var(--success-soft);
border: 1px solid var(--bp-gold-edge);
color: var(--success);
font-family: var(--font-display, Arial, sans-serif);
font-weight: var(--display-weight, 800);
font-size: .875rem;
line-height: 1.1;
letter-spacing: .06em;
text-transform: uppercase;
white-space: nowrap;
box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / .55),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35);
}
.cf-bundle-picker .bp-flag svg { width: 1rem; height: 1rem; flex: none; }
.cf-bundle-picker .bp-cardhead {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: .25rem;
padding: 1.35rem 2.75rem 1.05rem;
background: var(--band, #0f2747);
color: var(--band-ink, #fff);
border-radius: calc(var(--bp-radius) + 3px) calc(var(--bp-radius) + 3px) 0 0;
box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / .12),inset 0 -1px 0 oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .22);
text-align: center;
transition: background-color .22s ease;
}
.cf-bundle-picker .bp-card[data-selected] .bp-cardhead {background:var(--band); }
.cf-bundle-picker .bp-qty {
font-family: var(--font-display, Arial, sans-serif);
font-weight: var(--display-weight, 900);
font-size: clamp(1.5rem, 1rem + 1.1vw, 1.875rem);
line-height: 1.05;
letter-spacing: var(--display-tracking, -0.01em);
text-transform: var(--display-case, uppercase);
}
.cf-bundle-picker .bp-note { font-size: .9375rem; font-weight: 600; line-height: 1.3; color: var(--band-ink, #fff); }
.cf-bundle-picker .bp-radio {
position: absolute;
left: .95rem;
top: 50%;
translate: 0 -50%;
display: grid;
place-items: center;
width: 1.6rem;
height: 1.6rem;
border-radius: var(--field-radius, var(--radius, 999px));
border:2px solid oklch(from var(--band-ink, #fff) l c h / 0.72);
color: var(--field-ink, var(--ink));
transition: background-color .2s ease, border-color .2s ease;
border-color: var(--field-border, var(--band-ink));
}
.cf-bundle-picker .bp-radio svg { width: 1rem; height: 1rem; opacity: 0; transform: scale(.4); transition: opacity .2s ease, transform .25s var(--bp-ease); }
.cf-bundle-picker .bp-card[data-selected] .bp-radio { background: var(--success); border-color:var(--band-ink,#fff); color: var(--card); }
.cf-bundle-picker .bp-card[data-selected] .bp-radio svg { opacity: 1; transform: scale(1); }
.cf-bundle-picker .bp-body { display: flex; flex-direction: column; flex: 1; }
.cf-bundle-picker .bp-media {
position: relative;
display: grid;
place-items: end center;
aspect-ratio: 4 / 3;
padding: 1.25rem 1.5rem .75rem;background:var(--card);
border-bottom: 1px solid var(--bp-line);
overflow: hidden;
}
.cf-bundle-picker .bp-media::before {
content: '';
position: absolute;
left: 20%;
right: 20%;
bottom: 6%;
height: 9%;
border-radius:50%;background:transparent;
}
.cf-bundle-picker .bp-media img {
position: relative;
display: block;
width: 100%;
height: 100%;
object-fit: contain;
mix-blend-mode: normal;
transition: transform .3s var(--bp-ease);
}
.cf-bundle-picker .bp-card:hover .bp-media img { transform: translateY(-3px) scale(1.02); }
.cf-bundle-picker .bp-card[data-disabled]:hover .bp-media img { transform: none; }
.cf-bundle-picker .bp-pricing {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
padding: 1.35rem 1.25rem 1.5rem;
text-align: center;
}
.cf-bundle-picker .bp-unit { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: center; gap: .1rem .45rem; }
.cf-bundle-picker .bp-unit-num {
font-family: var(--font-display, Arial, sans-serif);
font-weight: var(--display-weight, 900);
font-size: clamp(2.5rem, 1.6rem + 2.2vw, 3.25rem);
line-height: 1;
letter-spacing: var(--display-tracking, -0.035em);
font-variant-numeric: tabular-nums;
color: var(--ink, #101828);
text-transform: var(--display-case, none);
}
.cf-bundle-picker .bp-unit-per { font-size: 1rem; font-weight: 700; color: var(--muted, #4a5565); }
.cf-bundle-picker .bp-total {
margin-top: .85rem;
font-size: 1.0625rem;
font-weight: 500;
line-height: 1.35;
color: var(--muted, #4a5565);
}
.cf-bundle-picker .bp-total s {
margin-right: .4rem;
text-decoration-thickness: 2px;
text-decoration-color: var(--danger);
color: var(--danger);
}
.cf-bundle-picker .bp-total b { font-weight: 800; color: var(--ink, #101828); }
.cf-bundle-picker .bp-save {
display: inline-flex;
align-items: center;
gap: .4rem;
margin-top: .8rem;
padding: .4rem .85rem;
border-radius: 999px;
background: var(--bp-save-bg);
border: 1px solid var(--bp-save-line);
color: var(--bp-save-ink);
font-size: .9375rem;
font-weight: 800;
line-height: 1.2;
}
.cf-bundle-picker .bp-save svg { width: 1rem; height: 1rem; flex: none; }
.cf-bundle-picker .bp-save--none {
background: color-mix(in oklch, var(--ink, #101828) 5%, var(--card, #fff));
border-color: var(--bp-line);
color: var(--muted, #4a5565);
font-weight: 700;
}
/* response card */
.cf-bundle-picker .bp-action {
position: relative;
max-width: 36rem;
margin: 2.75rem auto 0;
padding: clamp(1.25rem, 1rem + 1.5vw, 1.875rem);
background: var(--card, #fff);
border: 1px solid var(--card-border, var(--bp-line));
border-radius: var(--card-radius, calc(var(--bp-radius) + 4px));
box-shadow:var(--card-shadow, inset 0 0 0 4px oklch(from var(--band, #0f2747) l c h / 0.04),var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));
text-align: center;
}
.cf-bundle-picker .bp-action::before {
content: '';
position: absolute;
top: -10px;
left: 50%;
width: 18px;
height: 18px;
translate: -50% 0;
rotate: 45deg;
background: var(--card, #fff);
border-top: 1px solid var(--bp-line);
border-left: 1px solid var(--bp-line);
}
.cf-bundle-picker .bp-summary {
margin: 0 0 1.2rem;
font-size: 1.125rem;
line-height: 1.45;
color: var(--muted, #4a5565);
text-wrap: balance;
}
.cf-bundle-picker .bp-summary-inner { display: flex; flex-direction: column; align-items: center; gap: .6rem; animation: bp-swap .35s ease-out; }
.cf-bundle-picker .bp-summary b { font-weight: 800; color: var(--ink, #101828); }
.cf-bundle-picker .bp-summary-lead { font-weight: 600; }
.cf-bundle-picker .bp-sep { margin: 0 .45rem; color: var(--muted, #4a5565); }
.cf-bundle-picker .bp-summary-save {
display: inline-flex;
align-items: center;
gap: .4rem;
padding: .3rem .85rem;
border-radius: 999px;
background: var(--bp-save-bg);
border: 1px solid var(--bp-save-line);
color: var(--bp-save-ink);
font-size: .9375rem;
font-weight: 800;
}
.cf-bundle-picker .bp-summary-save svg { width: 1rem; height: 1rem; }
.cf-bundle-picker .bp-error {
display: flex;
align-items: flex-start;
gap: .6rem;
margin: 0 0 1rem;
padding: .8rem 1rem;
border-radius: var(--bp-radius);
background: var(--danger-soft);
border: 1px solid var(--card);
color: var(--danger);
font-size: 1rem;
font-weight: 600;
line-height: 1.4;
text-align: left;
text-wrap: pretty;
}
.cf-bundle-picker .bp-error svg { flex: none; width: 1.25rem; height: 1.25rem; margin-top: .05rem; }
/* the Belcher-weight order button */
.cf-bundle-picker .bp-btn {
position: relative;
isolation: isolate;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
gap: .65rem;
width: 100%;
min-height: 4.25rem;
margin: 0 0 5px;
padding: .95rem 1.25rem;
border: 1px solid color-mix(in oklch, var(--button-bg-2, var(--cta-2, #b42318)) 70%, var(--ink));
border-radius: var(--button-radius, var(--bp-radius));
background: linear-gradient(180deg,var(--button-bg,var(--cta)),var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h)));
color: var(--button-ink, var(--cta-ink, #fff));
font-family: var(--button-font, var(--font-display, Arial, sans-serif));
font-weight: var(--button-weight, 800);
font-size: clamp(1.0625rem, .8rem + 1.2vw, 1.375rem);
line-height: 1.15;
letter-spacing: -0.005em;
text-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75));
cursor: pointer;
box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / .38),inset 0 -4px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h),var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));
transition: transform .14s ease, box-shadow .14s ease, filter .2s ease;
text-transform: var(--button-case, none);
}
.cf-bundle-picker .bp-btn::after {
content: '';
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: -60%;
width: 40%;
background: linear-gradient(100deg, oklch(from var(--card) l c h / 0), oklch(from var(--card) l c h / 0.32), oklch(from var(--card) l c h / 0));
transform: skewX(-18deg);
transition: left .6s var(--bp-ease);
}
.cf-bundle-picker .bp-btn-label { text-align: center; text-wrap: balance; }
.cf-bundle-picker .bp-btn-icon { flex: none; width: 1.2em; height: 1.2em; }
.cf-bundle-picker .bp-btn:hover:not(:disabled), .cf-bundle-picker .bp-btn[data-force='hover'] {
filter:none;
transform: translateY(-1px);
;background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.06) c h)}
.cf-bundle-picker .bp-btn:hover:not(:disabled)::after, .cf-bundle-picker .bp-btn[data-force='hover']::after { left: 125%; }
.cf-bundle-picker .bp-btn:active:not(:disabled), .cf-bundle-picker .bp-btn[data-force='active'] {
filter:none;
transform: translateY(2px);
box-shadow:var(--button-shadow, inset 0 2px 4px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / .22),inset 0 -1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h),var(--shadow-sm, 0 1px 1px oklch(0.22 0.03 260 / 0.18), 0 1px 3px oklch(0.22 0.03 260 / 0.14)));
;background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.06) c h)}
.cf-bundle-picker .bp-btn:focus-visible { outline: 3px solid var(--accent, #0f5fc2); outline-offset: 5px; }
.cf-bundle-picker .bp-btn[aria-busy] { cursor: progress; filter: saturate(.92); }
.cf-bundle-picker .bp-btn:disabled {
background: var(--card);
border-color: var(--card);
color: var(--ink);
text-shadow: none;
cursor: not-allowed;
box-shadow: none;
transform: none;
filter: none;
}
.cf-bundle-picker .bp-btn:disabled::after { display: none; }
.cf-bundle-picker .bp-spin { animation: bp-spin .8s linear infinite; }
.cf-bundle-picker .bp-reassure {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: .45rem 1.25rem;
margin-top: 1.2rem;
font-size: .9375rem;
font-weight: 600;
line-height: 1.35;
color: var(--muted, #4a5565);
}
.cf-bundle-picker .bp-reassure span { display: inline-flex; align-items: center; gap: .4rem; }
.cf-bundle-picker .bp-reassure svg { width: 1.05rem; height: 1.05rem; flex: none; }
.cf-bundle-picker .bp-reassure-guarantee svg { color: var(--success); }
.cf-bundle-picker .bp-pay {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: .4rem;
margin-top: .9rem;
padding: 0;
list-style: none;
}
.cf-bundle-picker .bp-pay li { display: flex; }
.cf-bundle-picker .bp-pay svg { display: block; height: auto; }
@keyframes bp-rise { from { opacity: .82; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes bp-swap { from { opacity: .45; translate: 0 3px; } to { opacity: 1; translate: 0 0; } }
@keyframes bp-spin { to { transform: rotate(360deg); } }
/* tablet and phone: stacked rows, product beside the price */
@media (max-width: 820px) {
.cf-bundle-picker .bp-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.cf-bundle-picker .bp-cardhead {
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: .75rem;
padding: .85rem 1rem;
text-align: left;
}
.cf-bundle-picker .bp-card[data-best] .bp-cardhead { padding-top: 1.2rem; }
.cf-bundle-picker .bp-radio { position: static; translate: none; flex: none; border-color: var(--field-border, var(--band-ink)); }
.cf-bundle-picker .bp-qty { font-size: 1.375rem; }
.cf-bundle-picker .bp-note { margin-left: auto; font-size: .875rem; text-align: right; }
.cf-bundle-picker .bp-flag { left: auto; right: .9rem; transform: translateY(-50%); }
.cf-bundle-picker .bp-body--media { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); }
.cf-bundle-picker .bp-media {
aspect-ratio: auto;
place-items: center;
padding: .6rem;
border-bottom: 0;
border-right: 1px solid var(--bp-line);
border-radius: 0 0 0 calc(var(--bp-radius) + 3px);
}
.cf-bundle-picker .bp-media img { height: auto; max-height: 8.5rem; }
.cf-bundle-picker .bp-pricing { align-items: flex-start; text-align: left; padding: 1rem 1rem 1.15rem; }
.cf-bundle-picker .bp-unit { justify-content: flex-start; }
.cf-bundle-picker .bp-unit-num { font-size: 2.25rem; text-transform: var(--display-case, none); }
.cf-bundle-picker .bp-total { margin-top: .75rem; font-size: 1rem; }
.cf-bundle-picker .bp-save { margin-top: .65rem; font-size: .875rem; }
}
@media (max-width: 420px) {
.cf-bundle-picker .bp-qty { font-size: 1.25rem; }
.cf-bundle-picker .bp-body--media { grid-template-columns: 6.5rem minmax(0, 1fr); }
.cf-bundle-picker .bp-btn { padding-inline: 1rem; text-transform: var(--button-case, none); font-family: var(--button-font, var(--font-body)); }
}
@media (prefers-reduced-motion: reduce) {
.cf-bundle-picker *, .cf-bundle-picker *::before, .cf-bundle-picker *::after { animation: none !important; transition: none !important; }
.cf-bundle-picker .bp-card:hover, .cf-bundle-picker .bp-card[data-selected], .cf-bundle-picker .bp-card:hover .bp-media img { transform: none; }
.cf-bundle-picker .bp-btn:hover:not(:disabled), .cf-bundle-picker .bp-btn[data-force='hover'] { transform: none; }
.cf-bundle-picker .bp-btn::after { display: none; }
}
`
pieces/offer/bundle-picker/specimen.tsx 56 lines
import { slot } from "../../slots";
import __studioImageed5265ed from "../assets/119444547a3af8a6.webp";
import __studioImagee8b2bdbc from "../assets/76abe5e9f6b4d865.webp";
import __studioImagebf9506c6 from "../assets/a23b8a6ba7d6dfd1.webp";
import * as React from 'react'
import BundlePicker from '../bundle-picker'
import defaults from '../../studio-defaults.json'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
type SpecimenState = 'default' | 'hover' | 'active' | 'disabled' | 'error'
const sample = defaults.sample
const singlePrice = Number(String(sample.price).replace(/[^0-9.]/g, '')) || 47
const guaranteeLine = sample.guarantee.charAt(0).toUpperCase() + sample.guarantee.slice(1)
const packages = [
{
units: 1,
price: singlePrice,
note: '1-month supply',
image: __studioImageed5265ed,
imageAlt: 'One supplement bottle',
},
{
units: 3,
price: 129,
note: '3-month supply',
image: __studioImagee8b2bdbc,
imageAlt: 'Three supplement bottles',
},
{
units: 6,
price: 234,
note: '6-month supply',
image: __studioImagebf9506c6,
imageAlt: 'Six supplement bottles',
},
]
export default function BundlePickerSpecimen({ state = 'default' }: { state?: SpecimenState }) {
return (
<div>
<BundlePicker
headline='The more you stock up, the less you pay'
highlight='the less you pay'
lead={`Every package is covered by our ${sample.guarantee}.`}
packages={packages.map((pkg, index) => ({ ...pkg, image: slot(`item-${index + 1}`, pkg.image) }))}
unit={{ one: 'Bottle', other: 'Bottles' }}
guarantee={guaranteeLine}
secureLabel='Secure checkout'
state={state === 'default' ? undefined : state}
/>
</div>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalBundlePicker |
string |
Default 'The more you stock up, the less you pay'
|
highlight OptionalBundlePicker |
string |
Default 'the less you pay'
|
lead OptionalBundlePicker |
string |
|
packages OptionalBundlePicker |
BundlePackage[] |
Default DEFAULT_PACKAGES
|
unit OptionalBundlePicker |
{ one: string; other: string } |
Default { one: 'Bottle', other: 'Bottles' }
|
defaultSelected OptionalBundlePicker |
number |
|
currency OptionalBundlePicker |
string |
Default 'USD'
|
locale OptionalBundlePicker |
string |
Default 'en-US'
|
buttonLabel OptionalBundlePicker |
(ctx: BundleLabelContext) => string |
Default ({ units, unitWord }) => `Yes! Send Me ${units} ${unitWord}`
|
loadingLabel OptionalBundlePicker |
string |
Default 'Adding to your order…'
|
bestValueLabel OptionalBundlePicker |
string |
Default 'Best value'
|
secureLabel OptionalBundlePicker |
string |
Default ''
|
guarantee OptionalBundlePicker |
string |
Default '30-day money-back guarantee'
|
showPaymentMarks OptionalBundlePicker |
boolean |
Default true
|
errorMessage OptionalBundlePicker |
string |
Default 'We couldn’t add that to your order. Please try again.'
|
successTitle OptionalBundlePicker |
(ctx: BundleLabelContext) => string |
|
successBody OptionalBundlePicker |
string |
|
changeLabel OptionalBundlePicker |
string |
|
state OptionalBundlePicker |
BundlePickerState |
|
onSelect OptionalBundlePicker |
(pkg: BundlePackage, index: number) => void |
|
onSubmit OptionalBundlePicker |
(pkg: BundlePackage, index: number) => void | Promise<void> |
|
copy OptionalBundlePicker |
Partial<BundlePickerCopy> |
|
paymentLabels OptionalBundlePicker |
Partial<Record<'Visa' | 'Mastercard' | 'American Express' | 'Discover', string>> |
|
className OptionalBundlePicker |
string |
|
style OptionalBundlePicker |
React.CSSProperties |
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.
--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-border--field-focus--field-ink--field-radius- 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.
item-*- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
119444547a3af8a6.webp
image/webp · 19.3 KB
-
76abe5e9f6b4d865.webp
image/webp · 25.5 KB
-
a23b8a6ba7d6dfd1.webp
image/webp · 43.6 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB