Bundle Picker 8
Lets buyers pick a 1, 3 or 6 supply from a segmented header and see its per-unit price and calculated saving.
Use it in a prompt
Use offer/bundle-picker-8 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-8.tsx. - Import it and pass your copy and images (Props tab):
import { BundlePicker8 } from "@/components/funneldna/offer/bundle-picker-8"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/bundle-picker-8/component.tsx 826 lines
// Lets buyers pick a 1, 3 or 6 supply from a segmented header and see its per-unit price and calculated saving.
// layout: segmented-stepper
'use client'
import * as React from 'react'
import { AlertCircle, Check, Loader2, Lock } from 'lucide-react'
// Official payment-network marks retain their brand colours.
import { AmericanExpress, Discover, Mastercard, Visa } from 'react-svg-credit-card-payment-icons/icons/flat-rounded'
export type BundlePicker8Props = {
headline?: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
lead?: string
packages?: SupplyPackage[]
unit?: { one: string; other: string }
/** Index chosen on load; defaults to the best-value package. */
defaultSelected?: number
currency?: string
locale?: string
buttonLabel?: (ctx: SupplyContext) => string
loadingLabel?: string
bestValueLabel?: string
perUnitLabel?: string
guarantee?: string
secureLabel?: string
showPaymentMarks?: boolean
/** Accessible names for the official payment marks. */
paymentLabels?: Partial<Record<'Visa' | 'Mastercard' | 'American Express' | 'Discover', string>>
errorMessage?: string
/** Deprecated: ignored. The builder wires what happens after the action. */
successTitle?: (ctx: SupplyContext) => 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?: BundlePicker8State
onSelect?: (pkg: SupplyPackage, index: number) => void
/** Called on submit with the chosen package. Without it the button does nothing visible. */
onSubmit?: (pkg: SupplyPackage, index: number) => void | Promise<void>
/** Templates use {unit}, {units}, {unitWord}, {total}, {savings} and {percent}. */
copy?: Partial<BundlePicker8Copy>
className?: string
style?: React.CSSProperties
}
export function BundlePicker8({
headline = 'Stock up and pay less for every bottle',
highlight = 'pay less for every bottle',
lead = 'Pick your supply. The more bottles you take, the lower your price per bottle.',
packages = DEFAULT_PACKAGES,
unit = { one: 'Bottle', other: 'Bottles' },
defaultSelected,
currency = 'USD',
locale = 'en-US',
buttonLabel = ({ units, unitWord }) => `Add ${units} ${unitWord} To Cart`,
loadingLabel = 'Adding to your cart…',
bestValueLabel = 'Best value',
perUnitLabel,
guarantee = '30-day money-back guarantee',
secureLabel = '',
showPaymentMarks = true,
paymentLabels = {},
errorMessage = 'We couldn’t add that to your cart. Please try again.',
state,
onSelect,
onSubmit,
copy,
className,
style,
}: BundlePicker8Props) {
const text = { ...DEFAULT_COPY, ...copy }
const uid = React.useId()
const titleId = `${uid}-title`
const groupName = `${uid}-supply`
const perUnit = perUnitLabel ?? formatCopy(text.perUnit, { unit: unit.one.toLowerCase() })
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<SupplyPackage | undefined>((m, p) => (!m || p.units < m.units ? p : m), undefined)
const baseUnit = base ? base.price / base.units : 0
return packages.map((p) => {
const per = 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 { per, compare, savings, pct, baseUnit }
})
}, [packages])
const bestIndex = React.useMemo(() => {
if (rows.length < 2) return -1
const min = Math.min(...rows.map((r) => r.per))
const hits = rows.filter((r) => Math.abs(r.per - min) < 0.005)
if (hits.length !== 1 || !(min < rows[0].baseUnit - 0.005)) return -1
return rows.findIndex((r) => Math.abs(r.per - 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 hasMedia = packages.some((p) => Boolean(p.image))
const choose = (i: number) => {
if (disabled || loading) return
setSelected(i)
if (status === 'error') setStatus('idle')
onSelect?.(packages[i], i)
}
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
if (!pkg || disabled || loading || !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: SupplyContext = {
units: pkg.units,
unitWord: wordFor(pkg.units),
total: money(pkg.price),
perUnit: money(row.per),
savings: money(row.savings),
percent: row.pct,
}
const best = bestIndex >= 0 ? rows[bestIndex] : undefined
const hint =
row.savings === 0 && best && bestIndex !== index
? formatCopy(text.upsell, {
percent: best.pct,
units: packages[bestIndex].units,
unitWord: wordFor(packages[bestIndex].units).toLowerCase(),
})
: ''
const announce = formatCopy(text.selected, { units: ctx.units, unitWord: ctx.unitWord.toLowerCase(), total: ctx.total })
return (
<section
className={['cf-bundle-picker-8', className].filter(Boolean).join(' ')}
style={style}
aria-labelledby={titleId}
data-force={forced}
data-disabled={disabled ? '' : undefined}
>
<style>{CSS}</style>
<header className='bp8-head'>
<h2 id={titleId} className='bp8-title'>
{withHighlight(headline, highlight)}
</h2>
{lead ? <p className='bp8-lead'>{lead}</p> : null}
</header>
<form className='bp8-card' onSubmit={handleSubmit} noValidate>
<fieldset className='bp8-tray' disabled={disabled || loading}>
<legend className='bp8-vh'>{text.legend}</legend>
<div className='bp8-segs' style={{ '--bp8-n': Math.max(packages.length, 1) } as React.CSSProperties}>
{packages.map((p, i) => {
const r = rows[i]
const on = i === index
return (
<label
key={p.id ?? `${p.units}-${i}`}
className='bp8-seg'
data-on={on ? '' : undefined}
data-thumb={p.image ? '' : undefined}
>
<input
className='bp8-vh'
type='radio'
name={groupName}
value={p.id ?? String(p.units)}
checked={on}
onChange={() => choose(i)}
/>
{i === bestIndex ? <span className='bp8-flag'>{bestValueLabel}</span> : null}
<span className='bp8-dot' aria-hidden='true' />
{p.image ? (
<span className='bp8-thumb' aria-hidden='true'>
<img src={p.image} alt='' width={76} height={76} loading='lazy' decoding='async' />
</span>
) : null}
<span className='bp8-seg-copy'>
<span className='bp8-seg-name'>
<span className='bp8-seg-num'>{p.units}</span> <span className='bp8-seg-word'>{wordFor(p.units)}</span>
</span>
<span className='bp8-seg-per'>
<b>{money(r.per)}</b> <span>{perUnit}</span>
</span>
{r.pct > 0 ? <span className='bp8-seg-save'>{formatCopy(text.save, { percent: r.pct })}</span> : null}
</span>
</label>
)
})}
</div>
</fieldset>
<div className='bp8-panel' data-media={hasMedia ? '' : undefined}>
{hasMedia ? (
<figure className='bp8-media'>
<div className='bp8-stage'>
{packages.map((p, i) =>
p.image ? (
<img
key={p.id ?? `${p.units}-${i}`}
className='bp8-shot'
data-on={i === index ? '' : undefined}
src={p.image}
alt={i === index ? p.imageAlt ?? '' : ''}
aria-hidden={i === index ? undefined : true}
width={1200}
height={900}
decoding='async'
/>
) : null
)}
</div>
<figcaption className='bp8-caption'>
{formatCopy(text.caption, { units: ctx.units, unitWord: ctx.unitWord.toLowerCase() })}
</figcaption>
</figure>
) : null}
<div className='bp8-block'>
<p className='bp8-vh' aria-live='polite'>
{announce}
</p>
{(
<>
<div className='bp8-order' key={'order-' + index}>
<h3 className='bp8-pkg'>
{ctx.units} {ctx.unitWord}
</h3>
<p className='bp8-price'>
<span className='bp8-big'>{ctx.perUnit}</span>
<span className='bp8-per'>{perUnit}</span>
</p>
<p className='bp8-total'>
{row.savings > 0 ? (
<>
<span className='bp8-vh'>{text.regular} </span>
<s>{money(row.compare)}</s>{' '}
</>
) : null}
<strong>{ctx.total}</strong> {text.totalToday}
</p>
{row.savings > 0 ? (
<p className='bp8-save'>
<Check aria-hidden='true' />
<span>{formatCopy(text.youSave, { savings: ctx.savings, percent: ctx.percent })}</span>
</p>
) : hint ? (
<p className='bp8-hint'>{hint}</p>
) : null}
</div>
<button
type='submit'
className='bp8-cta'
disabled={disabled}
aria-disabled={loading || undefined}
aria-busy={loading || undefined}
>
{loading ? (
<>
<Loader2 className='bp8-spin' aria-hidden='true' />
<span>{loadingLabel}</span>
</>
) : (
<span>{buttonLabel(ctx)}</span>
)}
</button>
{status === 'error' ? (
<p className='bp8-error' role='alert'>
<AlertCircle aria-hidden='true' />
<span>{errorMessage}</span>
</p>
) : null}
{secureLabel || guarantee ? (
<p className='bp8-assure'>
<Lock aria-hidden='true' />
<span>
{[secureLabel, guarantee].filter(Boolean).join(' · ')}
</span>
</p>
) : null}
{showPaymentMarks ? (
<ul className='bp8-pay' aria-label={text.payments}>
{PAYMENT_MARKS.map(([label, Icon]) => (
<li key={label}>
<Icon width={40} aria-label={paymentLabels[label] ?? label} />
</li>
))}
</ul>
) : null}
</>
)}
</div>
</div>
</form>
</section>
)
}
export default BundlePicker8
export type SupplyPackage = {
/** Number of units in the package, e.g. 1, 3, 6. */
units: number
/** Total price of the package in the chosen currency. */
price: number
/** Photo of this exact package (one bottle, three, six). Cropped with object-fit: cover, so any aspect works. */
image?: string
imageAlt?: string
/** Value posted for this package; defaults to the unit count. */
id?: string
}
export type BundlePicker8State = 'default' | 'hover' | 'active' | 'disabled' | 'loading' | 'error' | 'success'
export type SupplyContext = {
units: number
unitWord: string
total: string
perUnit: string
savings: string
percent: number
}
export type BundlePicker8Copy = {
legend: string
perUnit: string
save: string
youSave: string
totalToday: string
regular: string
upsell: string
caption: string
selected: string
payments: string
}
type Status = 'idle' | 'loading' | 'error'
const DEFAULT_PACKAGES: SupplyPackage[] = [
{ units: 1, price: 47 },
{ units: 3, price: 117 },
{ units: 6, price: 198 },
]
const DEFAULT_COPY: BundlePicker8Copy = {
legend: 'Choose your supply',
perUnit: 'per {unit}',
save: 'Save {percent}%',
youSave: 'You save {savings} ({percent}%)',
totalToday: 'total today',
regular: 'Regular price',
upsell: 'Save up to {percent}% when you choose {units} {unitWord}.',
caption: 'Your package: {units} {unitWord}',
selected: '{units} {unitWord} selected, {total} total',
payments: 'Accepted cards',
}
const PAYMENT_MARKS = [
['Visa', Visa],
['Mastercard', Mastercard],
['American Express', AmericanExpress],
['Discover', Discover],
] as const
const statusFrom = (s?: BundlePicker8State): Status =>
s === 'loading' || s === 'error' ? s : 'idle'
function formatCopy(template: string, vars: Record<string, string | number>) {
let out = template
for (const key of Object.keys(vars)) out = out.split('{' + key + '}').join(String(vars[key]))
return out
}
function withHighlight(text: string, phrase?: string) {
if (!phrase) return text
const at = text.toLowerCase().indexOf(phrase.toLowerCase())
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<mark className='bp8-mark'>{text.slice(at, at + phrase.length)}</mark>
{text.slice(at + phrase.length)}
</>
)
}
const CSS = `
.cf-bundle-picker-8 {
--bp8-r: var(--card-radius, var(--radius, 14px));
--bp8-in: max(0px, calc(var(--bp8-r) - 4px));
--bp8-line: var(--card-border, color-mix(in oklch, var(--ink) 12%, transparent));
--bp8-tray: color-mix(in oklch, var(--ink) 5%, var(--card));
--bp8-soft: color-mix(in oklch, var(--band-ink) 84%, var(--band));
--bp8-marker: color-mix(in oklch, var(--marker, #fae37c) 82%, transparent);
--bp8-ease: cubic-bezier(.2, .8, .2, 1);
width: 100%;
max-width: 1080px;
margin-inline: auto;
color: var(--ink);
font-family: var(--font-body);
font-size: 17px;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
.cf-bundle-picker-8 *, .cf-bundle-picker-8 *::before, .cf-bundle-picker-8 *::after { box-sizing: border-box; }
.cf-bundle-picker-8 :where(h2, h3, p, figure, fieldset, ul, legend) { margin: 0; }
.cf-bundle-picker-8 :where(fieldset) { border: 0; padding: 0; min-width: 0; }
.cf-bundle-picker-8 :where(ul) { list-style: none; padding: 0; }
.cf-bundle-picker-8 :where(img) { display: block; max-width: 100%; }
:where(.cf-bundle-picker-8) .bp8-vh {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* header */
:where(.cf-bundle-picker-8) .bp8-head { margin-bottom: clamp(24px, 3.4vw, 40px); }
:where(.cf-bundle-picker-8) .bp8-title {
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
letter-spacing: var(--display-tracking, -0.03em);
font-size: clamp(2.125rem, 1.25rem + 3.4vw, 3.75rem);
line-height: 1.03;
color: var(--ink);
text-wrap: balance;
}
:where(.cf-bundle-picker-8) .bp8-mark {
color: inherit;
background-color: transparent;
background-image: linear-gradient(177deg, transparent 0 50%, var(--bp8-marker) 50% 93%, transparent 93%);
padding: 0 .12em;
margin: 0 -.06em;
border-radius: .2em .35em .25em .4em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
:where(.cf-bundle-picker-8) .bp8-lead {
max-width: 52ch;
margin-top: clamp(14px, 1.4vw, 20px);
font-size: clamp(1.0625rem, .95rem + .45vw, 1.25rem);
font-weight: 500;
line-height: 1.5;
color: var(--muted);
text-wrap: pretty;
}
/* card + segmented header */
:where(.cf-bundle-picker-8) .bp8-card {
position: relative;
padding: clamp(10px, 1.3vw, 14px);
background: var(--card);
border: 1px solid var(--bp8-line);
border-radius: var(--bp8-r);
box-shadow: var(--card-shadow, var(--shadow-lg, 0 2px 4px oklch(0.22 0.03 260 / 0.22), 0 12px 24px -8px oklch(0.22 0.03 260 / 0.32)));
}
:where(.cf-bundle-picker-8) .bp8-tray {
padding: 20px 8px 8px;
background: var(--bp8-tray);
border-radius: var(--bp8-in);
}
:where(.cf-bundle-picker-8) .bp8-segs {
display: grid;
grid-template-columns: repeat(var(--bp8-n, 3), minmax(0, 1fr));
gap: 8px;
}
:where(.cf-bundle-picker-8) .bp8-seg {
position: relative;
display: grid;
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: 16px;
min-height: 104px;
padding: 16px 48px 16px 16px;
border-radius: max(0px, calc(var(--bp8-r) - 6px));
color: var(--ink);
cursor: pointer;
transition: background-color .2s ease, box-shadow .25s ease, transform .25s var(--bp8-ease);
}
:where(.cf-bundle-picker-8) .bp8-seg:not([data-on]):hover { background: color-mix(in oklch, var(--card) 65%, var(--bp8-tray)); }
:where(.cf-bundle-picker-8) .bp8-seg:not([data-on]):active { transform: scale(.985); }
:where(.cf-bundle-picker-8) .bp8-seg[data-on] {
background: var(--card);
box-shadow: inset 0 0 0 2px var(--ink), 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));
}
:where(.cf-bundle-picker-8) .bp8-seg:has(input:focus-visible) {
outline: 3px solid var(--field-focus, var(--accent));
outline-offset: 3px;
}
:where(.cf-bundle-picker-8) .bp8-tray:disabled .bp8-seg { cursor: default; }
:where(.cf-bundle-picker-8) .bp8-tray:disabled .bp8-seg:hover { background: transparent; }
:where(.cf-bundle-picker-8) .bp8-tray:disabled .bp8-seg[data-on]:hover { background: var(--card); }
.cf-bundle-picker-8[data-disabled] .bp8-seg { cursor: not-allowed; opacity: 1; }
:where(.cf-bundle-picker-8) .bp8-thumb { display: none; }
@media (min-width: 900px) {
:where(.cf-bundle-picker-8) .bp8-seg[data-thumb] { grid-template-columns: 76px minmax(0, 1fr); }
:where(.cf-bundle-picker-8) .bp8-thumb {
display: block;
width: 76px;
aspect-ratio: 1;
overflow: hidden;
border-radius: 10px;
background: var(--bp8-tray);
}
:where(.cf-bundle-picker-8) .bp8-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
}
:where(.cf-bundle-picker-8) input.bp8-vh { accent-color: var(--field-focus, var(--accent)); }
:where(.cf-bundle-picker-8) .bp8-dot {
position: absolute;
top: 16px;
right: 16px;
width: 22px;
height: 22px;
border-radius: 50%;
border: 2px solid color-mix(in oklch, var(--ink) 32%, transparent);
background: var(--card);
transition: border-color .2s ease, box-shadow .2s ease;
}
:where(.cf-bundle-picker-8) .bp8-seg[data-on] .bp8-dot {
border-color: var(--accent);
box-shadow: inset 0 0 0 4px var(--card), inset 0 0 0 11px var(--accent);
}
:where(.cf-bundle-picker-8) .bp8-seg-copy { display: grid; justify-items: start; gap: 4px; min-width: 0; }
:where(.cf-bundle-picker-8) .bp8-seg-name {
display: flex;
align-items: baseline;
gap: .28em;
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
font-size: clamp(1.25rem, .9rem + .9vw, 1.6rem);
line-height: 1.05;
letter-spacing: -0.015em;
}
:where(.cf-bundle-picker-8) .bp8-seg-per { font-size: 15px; line-height: 1.35; color: var(--muted); }
:where(.cf-bundle-picker-8) .bp8-seg-per b { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
:where(.cf-bundle-picker-8) .bp8-seg-save {
margin-top: 4px;
padding: 3px 10px;
border-radius: 999px;
background: var(--success-soft);
color: var(--success);
font-size: 13px;
font-weight: 800;
line-height: 1.35;
white-space: nowrap;
}
:where(.cf-bundle-picker-8) .bp8-flag {
position: absolute;
top: -12px;
left: 14px;
z-index: 1;
padding: 4px 11px;
border-radius: 999px;
background: var(--band);
color: var(--band-ink);
font-size: 12px;
font-weight: 800;
letter-spacing: .06em;
line-height: 1.3;
text-transform: uppercase;
white-space: nowrap;
box-shadow: 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));
}
/* active panel */
:where(.cf-bundle-picker-8) .bp8-panel {
display: grid;
gap: clamp(10px, 1.3vw, 14px);
margin-top: clamp(10px, 1.3vw, 14px);
}
@media (min-width: 820px) {
:where(.cf-bundle-picker-8) .bp8-panel[data-media] { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); }
}
:where(.cf-bundle-picker-8) .bp8-media { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; }
:where(.cf-bundle-picker-8) .bp8-stage {
position: relative;
overflow: hidden;
aspect-ratio: 4 / 3;
border-radius: var(--bp8-in);
background: var(--bp8-tray);
}
@media (min-width: 820px) {
:where(.cf-bundle-picker-8) .bp8-stage { flex: 1; aspect-ratio: auto; min-height: 440px; }
}
:where(.cf-bundle-picker-8) .bp8-shot {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
opacity: 0;
transform: scale(1.035);
transition: opacity .45s ease, transform .7s var(--bp8-ease);
}
:where(.cf-bundle-picker-8) .bp8-shot[data-on] { opacity: 1; transform: none; }
:where(.cf-bundle-picker-8) .bp8-caption {
padding: 0 8px 4px;
color: var(--ink);
font-size: 15px;
font-weight: 700;
line-height: 1.3;
text-align: center;
text-wrap: balance;
}
/* the bold order block */
:where(.cf-bundle-picker-8) .bp8-block {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
padding: clamp(24px, 3.2vw, 40px);
border-radius: var(--bp8-in);
background: var(--band);
color: var(--band-ink);
}
:where(.cf-bundle-picker-8) .bp8-order { display: flex; flex-direction: column; align-items: flex-start; }
@keyframes bp8-rise { from { opacity: .35; transform: translateY(8px); } to { opacity: 1; transform: none; } }
:where(.cf-bundle-picker-8) .bp8-order > * { animation: bp8-rise .4s var(--bp8-ease) both; }
:where(.cf-bundle-picker-8) .bp8-order > :nth-child(2) { animation-delay: .04s; }
:where(.cf-bundle-picker-8) .bp8-order > :nth-child(3) { animation-delay: .08s; }
:where(.cf-bundle-picker-8) .bp8-order > :nth-child(4) { animation-delay: .12s; }
:where(.cf-bundle-picker-8) .bp8-pkg {
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
font-size: clamp(1.5rem, 1.1rem + 1.1vw, 2rem);
line-height: 1.1;
letter-spacing: var(--display-tracking, -0.015em);
color: var(--band-ink);
}
:where(.cf-bundle-picker-8) .bp8-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 12px; }
:where(.cf-bundle-picker-8) .bp8-big {
font-family: var(--font-display);
font-weight: var(--display-weight, 800);
font-size: clamp(3.25rem, 2.3rem + 3.4vw, 5rem);
line-height: 1;
letter-spacing: -0.04em;
font-variant-numeric: tabular-nums;
color: var(--band-ink);
}
:where(.cf-bundle-picker-8) .bp8-per { font-size: 18px; font-weight: 600; color: var(--bp8-soft); }
:where(.cf-bundle-picker-8) .bp8-total { margin-top: 16px; font-size: 18px; line-height: 1.4; color: var(--bp8-soft); text-wrap: pretty; }
:where(.cf-bundle-picker-8) .bp8-total s { margin-right: .2em; text-decoration-thickness: 2px; color: var(--danger); background: var(--danger-soft); }
:where(.cf-bundle-picker-8) .bp8-total strong { font-weight: 800; color: var(--band-ink); }
:where(.cf-bundle-picker-8) .bp8-save {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 12px;
padding: 7px 14px 7px 10px;
border-radius: 999px;
background: var(--success-soft);
color: var(--success);
font-size: 15px;
font-weight: 800;
line-height: 1.3;
}
:where(.cf-bundle-picker-8) .bp8-save svg { width: 18px; height: 18px; flex: none; stroke-width: 3; }
:where(.cf-bundle-picker-8) .bp8-hint { margin-top: 12px; font-size: 16px; line-height: 1.45; color: var(--bp8-soft); text-wrap: pretty; }
/* the button */
:where(.cf-bundle-picker-8) .bp8-cta {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
width: 100%;
min-height: 66px;
margin-top: 26px;
padding: 14px 22px;
border: 0;
border-radius: var(--button-radius, var(--radius, 10px));
background: linear-gradient(180deg, var(--button-bg, var(--cta)) 0%, var(--button-bg-2, var(--cta-2)) 100%);
color: var(--button-ink, var(--cta-ink)); text-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75));
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, 1rem + .45vw, 1.3rem);
line-height: 1.15;
letter-spacing: -0.005em;
text-align: center;
text-wrap: balance;
cursor: pointer;
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + 0.12) c h / 0.5),inset 0 -3px 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 .16s var(--bp8-ease), box-shadow .16s ease, filter .16s ease;
-webkit-tap-highlight-color: transparent;
}
:where(.cf-bundle-picker-8) .bp8-cta:hover:not(:disabled),
.cf-bundle-picker-8[data-force='hover'] .bp8-cta:not(:disabled) {
transform: translateY(-2px);
background: linear-gradient(180deg, oklch(from var(--button-bg, var(--cta)) calc(l - .02) c h), var(--button-bg-2, var(--cta-2)));
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l + 0.12) c h / 0.5),inset 0 -3px 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)));
}
:where(.cf-bundle-picker-8) .bp8-cta:active:not(:disabled),
.cf-bundle-picker-8[data-force='active'] .bp8-cta:not(:disabled) {
transform: translateY(2px);
background: var(--button-bg-2, var(--cta-2));
box-shadow: var(--button-shadow, inset 0 3px 6px oklch(from var(--band) calc(l - .12) c h / .28), inset 0 0 0 1px oklch(from var(--band) calc(l - .12) c h / .16), 0 1px 0 oklch(from var(--band) calc(l - .12) c h / .25));
}
:where(.cf-bundle-picker-8) .bp8-cta:focus-visible { outline: 3px solid var(--band-ink); outline-offset: 3px; }
:where(.cf-bundle-picker-8) .bp8-cta:disabled {
cursor: not-allowed;
background: var(--button-2-bg, var(--card));
color: var(--button-2-ink, var(--muted)); text-shadow: none;
box-shadow: none;
filter: none;
}
:where(.cf-bundle-picker-8) .bp8-cta[aria-busy='true'] { cursor: progress; }
@keyframes bp8-spin { to { transform: rotate(360deg); } }
:where(.cf-bundle-picker-8) .bp8-spin { width: 22px; height: 22px; flex: none; animation: bp8-spin .9s linear infinite; }
:where(.cf-bundle-picker-8) .bp8-error {
display: flex;
align-items: flex-start;
gap: 10px;
margin-top: 14px;
padding: 12px 14px;
border-radius: max(0px, calc(var(--bp8-r) - 6px));
background: var(--danger-soft);
color: var(--danger);
font-size: 15px;
font-weight: 700;
line-height: 1.4;
text-wrap: pretty;
}
:where(.cf-bundle-picker-8) .bp8-error svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
:where(.cf-bundle-picker-8) .bp8-assure {
display: block;
margin-top: 16px;
font-size: 15px;
font-weight: 600;
line-height: 1.4;
color: var(--bp8-soft);
text-align: center;
text-wrap: pretty;
}
:where(.cf-bundle-picker-8) .bp8-assure svg { width: 16px; height: 16px; display: inline-block; vertical-align: -0.15em; margin-inline-end: .4em; }
:where(.cf-bundle-picker-8) .bp8-pay { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
:where(.cf-bundle-picker-8) .bp8-pay svg { display: block; width: 40px; height: auto; }
/* phones */
@media (max-width: 640px) {
:where(.cf-bundle-picker-8) .bp8-tray { padding: 18px 6px 6px; }
:where(.cf-bundle-picker-8) .bp8-segs { gap: 6px; }
:where(.cf-bundle-picker-8) .bp8-seg { justify-items: center; gap: 0; min-height: 0; padding: 18px 6px 12px; text-align: center; }
:where(.cf-bundle-picker-8) input.bp8-vh { accent-color: var(--field-focus, var(--accent)); }
:where(.cf-bundle-picker-8) .bp8-dot { display: none; }
:where(.cf-bundle-picker-8) .bp8-seg-copy { justify-items: center; gap: 2px; }
:where(.cf-bundle-picker-8) .bp8-seg-name { flex-direction: column; align-items: center; gap: 2px; }
:where(.cf-bundle-picker-8) .bp8-seg-num { font-size: 2rem; line-height: 1; }
:where(.cf-bundle-picker-8) .bp8-seg-word { font-family: var(--font-body); font-size: 14px; font-weight: 700; letter-spacing: 0; }
:where(.cf-bundle-picker-8) .bp8-seg-per { display: grid; font-size: 14px; }
:where(.cf-bundle-picker-8) .bp8-seg-per b { font-size: 16px; }
:where(.cf-bundle-picker-8) .bp8-seg-save { margin-top: 6px; padding: 2px 8px; font-size: 12px; }
:where(.cf-bundle-picker-8) .bp8-flag { left: 50%; transform: translateX(-50%); padding: 3px 8px; font-size: 11px; letter-spacing: .03em; }
:where(.cf-bundle-picker-8) .bp8-block { padding: 24px 20px; }
:where(.cf-bundle-picker-8) .bp8-cta { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
.cf-bundle-picker-8 *, .cf-bundle-picker-8 *::before, .cf-bundle-picker-8 *::after { animation: none !important; transition-duration: .01ms !important; }
:where(.cf-bundle-picker-8) .bp8-shot { transform: none; }
:where(.cf-bundle-picker-8) .bp8-cta:hover, :where(.cf-bundle-picker-8) .bp8-cta:active, .cf-bundle-picker-8[data-force] .bp8-cta, :where(.cf-bundle-picker-8) .bp8-seg:active { transform: none !important; }
}
`
pieces/offer/bundle-picker-8/specimen.tsx 50 lines
import __studioImagebd396142 from "../assets/2bfee218c102f676.webp";
import __studioImagefac18af7 from "../assets/eb0ae9c79a4bdb7c.webp";
import __studioImage1fa77947 from "../assets/428c4ac9ffd85403.webp";
import * as React from 'react'
import { BundlePicker8, type BundlePicker8State } from '../bundle-picker-8'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
function priceOf(value: string, fallback: number) {
const n = Number.parseFloat(value.replace(/[^0-9.]/g, ''))
return Number.isFinite(n) && n > 0 ? n : fallback
}
export default function BundlePicker8Specimen({ state = 'default' }: { state?: string }) {
const single = priceOf(defaults.sample.price, 47)
const packages = [
{
units: 1,
price: single,
id: 'supply-1',
image: slot('item-1', __studioImagebd396142),
imageAlt: 'One supplement bottle on a light grey studio backdrop',
},
{
units: 3,
price: 117,
id: 'supply-3',
image: slot('item-2', __studioImagefac18af7),
imageAlt: 'Three supplement bottles grouped on a light grey studio backdrop',
},
{
units: 6,
price: 198,
id: 'supply-6',
image: slot('item-3', __studioImage1fa77947),
imageAlt: 'Six supplement bottles in two rows on a light grey studio backdrop',
},
]
return (
<BundlePicker8
state={state as BundlePicker8State}
guarantee={defaults.sample.guarantee}
secureLabel='Secure checkout'
packages={packages}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalBundlePicker8 |
string |
Default 'Stock up and pay less for every bottle'
|
highlight OptionalBundlePicker8 |
string |
Default 'pay less for every bottle'
|
lead OptionalBundlePicker8 |
string |
Default 'Pick your supply. The more bottles you take, the lower your price per bottle.'
|
packages OptionalBundlePicker8 |
SupplyPackage[] |
Default DEFAULT_PACKAGES
|
unit OptionalBundlePicker8 |
{ one: string; other: string } |
Default { one: 'Bottle', other: 'Bottles' }
|
defaultSelected OptionalBundlePicker8 |
number |
|
currency OptionalBundlePicker8 |
string |
Default 'USD'
|
locale OptionalBundlePicker8 |
string |
Default 'en-US'
|
buttonLabel OptionalBundlePicker8 |
(ctx: SupplyContext) => string |
Default ({ units, unitWord }) => `Add ${units} ${unitWord} To Cart`
|
loadingLabel OptionalBundlePicker8 |
string |
Default 'Adding to your cart…'
|
bestValueLabel OptionalBundlePicker8 |
string |
Default 'Best value'
|
perUnitLabel OptionalBundlePicker8 |
string |
|
guarantee OptionalBundlePicker8 |
string |
Default '30-day money-back guarantee'
|
secureLabel OptionalBundlePicker8 |
string |
Default ''
|
showPaymentMarks OptionalBundlePicker8 |
boolean |
Default true
|
paymentLabels OptionalBundlePicker8 |
Partial<Record<'Visa' | 'Mastercard' | 'American Express' | 'Discover', string>> |
Default {}
|
errorMessage OptionalBundlePicker8 |
string |
Default 'We couldn’t add that to your cart. Please try again.'
|
successTitle OptionalBundlePicker8 |
(ctx: SupplyContext) => string |
|
successBody OptionalBundlePicker8 |
string |
|
changeLabel OptionalBundlePicker8 |
string |
|
state OptionalBundlePicker8 |
BundlePicker8State |
|
onSelect OptionalBundlePicker8 |
(pkg: SupplyPackage, index: number) => void |
|
onSubmit OptionalBundlePicker8 |
(pkg: SupplyPackage, index: number) => void | Promise<void> |
|
copy OptionalBundlePicker8 |
Partial<BundlePicker8Copy> |
|
className OptionalBundlePicker8 |
string |
|
style OptionalBundlePicker8 |
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.
--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-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.
item-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-3- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
2bfee218c102f676.webp
image/webp · 13.7 KB
-
428c4ac9ffd85403.webp
image/webp · 23 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
eb0ae9c79a4bdb7c.webp
image/webp · 14.8 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB