Bundle Picker 2
Supply staircase: 1, 3 and 6 units rise left to right as steps on a colour block, each with its per-unit price
Use it in a prompt
Use offer/bundle-picker-2 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-2.tsx. - Import it and pass your copy and images (Props tab):
import { BundlePicker2 } from "@/components/funneldna/offer/bundle-picker-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/bundle-picker-2/component.tsx 659 lines
// layout: price-staircase
// Supply staircase: 1, 3 and 6 units rise left to right as steps on a colour block, each with its per-unit price
// computed from the supplied prices, so climbing to the bigger supply reads as the better deal; the button names the pick.
'use client'
import * as React from 'react'
import { AlertCircle, Check, Loader2, Lock, ShieldCheck, TrendingDown, Truck } from 'lucide-react'
import { FX_HOST, Pattern } from '../fx/fx'
export type SupplyStep = {
/** Number of units in this supply, e.g. 1, 3, 6. */
units: number
/** Price of this supply in the chosen currency. */
price: number
/** Shipping cost for this supply; 0 reads as free. Leave out to show no shipping line. */
shipping?: number
/** Short note under the step; defaults to a shipping note built from shipping. */
note?: string
/** Cut-out shot of this exact supply (one jar, three, six) on a transparent background. */
image?: string
/** Alt text for the supply shot; defaults to copy.imageAlt when a product name is set. */
imageAlt?: string
/** Value passed back for this supply; defaults to the unit count. */
id?: string
}
export type BundlePicker2State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
/** Facts about the chosen supply, passed to a function buttonLabel. */
export type BundlePicker2Context = {
units: number
unitWord: string
price: string
total: string
perUnit: string
savings: string
product: string
}
/**
* Copy templates. Named placeholders are replaced as text: {units}, {unitWord} / {UnitWord} (singular or plural for
* the count), {unit} / {unitOther} (lower case), {price}, {total} (price plus shipping), {perUnit}, {basePer} (the
* smallest supply's per-unit price), {compare}, {savings}, {shipping}, {product}, {guarantee}, {bestUnits},
* {bestWord}, {bestPer} and, in reasonsTitle, {count}.
*/
export type BundlePicker2Copy = {
/** Screen-reader legend for the supply choices. */
legend: string
/** Line on the colour block above the first step. */
ladder: string
cap: string
pick: string
perUnit: string
packTotal: string
shippingFree: string
shippingCost: string
saveLine: string
baseLine: string
reasonsTitle: string
/** Count phrases for reasonsTitle; index 0 is used for one reason. */
countWords: string[]
reasonDrop: string
reasonStart: string
reasonClimb: string
reasonShipFree: string
reasonGuarantee: string
receiptItems: string
receiptDiscount: string
receiptShipping: string
receiptFree: string
receiptTotal: string
/** Button text, used when no buttonLabel is supplied. */
button: string
/** Polite live-region announcement after a choice. */
live: string
imageAlt: string
}
export type BundlePicker2Props = {
headline?: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
/** Supporting line under the headline. */
lead?: string
/** Product name, used in the receipt and image alt text. */
product?: string
/** Supplies in climbing order; the last one is the top step. */
packages?: SupplyStep[]
/** Unit words for one and many, e.g. Jar / Jars. */
unit?: { one: string; other: string }
/** Index chosen on load; defaults to the best-value supply. */
defaultSelected?: number
/** ISO currency code for every price. */
currency?: string
/** Locale used to format prices. */
locale?: string
/** Template (copy placeholders) or a function of the chosen supply; takes precedence over copy.button. */
buttonLabel?: string | ((ctx: BundlePicker2Context) => string)
/** Button text while onSubmit is pending. */
loadingLabel?: string
/** Shown only on the supply whose per-unit price is lowest by the supplied prices. */
bestValueLabel?: string
/** Supplied guarantee; empty hides it. */
guarantee?: string
/** Reassurance under the button; empty hides it. */
secureLabel?: string
/** Shown when onSubmit rejects. */
errorMessage?: string
/** Replaces the computed numbered reasons; each entry may use the copy placeholders. */
reasons?: string[]
/** Forces a preview state. */
state?: BundlePicker2State
/** Called whenever a supply is chosen. */
onSelect?: (pkg: SupplyStep, index: number) => void
/** Called with the chosen supply. A rejected promise shows the inline error. */
onSubmit?: (pkg: SupplyStep, index: number) => void | Promise<void>
copy?: Partial<BundlePicker2Copy>
className?: string
style?: React.CSSProperties
}
type Status = 'idle' | 'loading' | 'error'
export function BundlePicker2(props: BundlePicker2Props) {
const {
headline = 'Climb the staircase and pay less for every jar',
highlight = 'pay less for every jar',
lead = 'Pick 1, 3 or 6 jars. Each step up lowers the price of every jar in your order.',
product = '',
packages = DEFAULT_PACKAGES,
unit = { one: 'Jar', other: 'Jars' },
defaultSelected,
currency = 'USD',
locale = 'en-US',
buttonLabel,
loadingLabel = 'Adding to your order…',
bestValueLabel = 'Best value',
guarantee = '30-day money-back guarantee',
secureLabel = 'Secure checkout',
errorMessage = 'We couldn’t add that to your order. Please try again.',
reasons,
state,
onSelect,
onSubmit,
copy,
className,
style,
} = props
const text: BundlePicker2Copy = { ...DEFAULT_COPY, ...copy }
const uid = React.useId()
const group = `${uid}-supply`
const titleId = `${uid}-title`
const errorId = `${uid}-error`
const money = React.useCallback((n: number) => formatMoney(n, locale, currency), [locale, currency])
const { rows, baseUnit } = React.useMemo(() => {
const valid = packages.filter((p) => p.units > 0)
const base = valid.reduce<SupplyStep | undefined>((m, p) => (!m || p.units < m.units ? p : m), undefined)
const baseU = base ? base.price / base.units : 0
const list = packages.map((p) => {
const per = p.units > 0 ? p.price / p.units : p.price
const compare = baseU * p.units
const raw = compare - p.price
return { per, compare, savings: raw > 0.005 ? raw : 0, total: p.price + (p.shipping ?? 0) }
})
return { rows: list, baseUnit: baseU }
}, [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 < baseUnit - 0.005)) return -1
return rows.findIndex((r) => Math.abs(r.per - min) < 0.005)
}, [rows, baseUnit])
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>(state === 'error' ? 'error' : 'idle')
React.useEffect(() => {
setStatus(state === 'error' ? 'error' : 'idle')
}, [state])
const [announce, setAnnounce] = React.useState('')
const alive = React.useRef(true)
React.useEffect(() => {
alive.current = true
return () => {
alive.current = false
}
}, [])
const disabled = state === 'disabled'
const loading = status === 'loading'
const n = packages.length
const index = Math.min(Math.max(selected, 0), Math.max(n - 1, 0))
const pkg = packages[index]
const row = rows[index]
const one = unit.one.toLowerCase()
const other = unit.other.toLowerCase()
const best = bestIndex >= 0 ? packages[bestIndex] : undefined
const hasMedia = packages.some((p) => Boolean(p.image))
const varsFor = (i: number): Record<string, string> => {
const p = packages[i]
const r = rows[i]
return {
units: String(p.units),
unitWord: p.units === 1 ? one : other,
UnitWord: p.units === 1 ? unit.one : unit.other,
unit: one,
unitOther: other,
price: money(p.price),
total: money(r.total),
perUnit: money(r.per),
basePer: money(baseUnit),
compare: money(r.compare),
savings: money(r.savings),
shipping: typeof p.shipping === 'number' ? money(p.shipping) : '',
product,
guarantee,
bestUnits: best ? String(best.units) : '',
bestWord: best ? (best.units === 1 ? one : other) : '',
bestPer: bestIndex >= 0 ? money(rows[bestIndex].per) : '',
}
}
const choose = (i: number) => {
if (disabled || loading) return
setSelected(i)
setAnnounce(fill(text.live, varsFor(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 vars = varsFor(index)
const ctx: BundlePicker2Context = {
units: pkg.units,
unitWord: vars.unitWord,
price: vars.price,
total: vars.total,
perUnit: vars.perUnit,
savings: vars.savings,
product,
}
const label = typeof buttonLabel === 'function' ? buttonLabel(ctx) : fill(buttonLabel ?? text.button, vars)
const computed: string[] = []
if (row.savings > 0) computed.push(text.reasonDrop)
else {
computed.push(text.reasonStart)
if (best && bestIndex !== index) computed.push(text.reasonClimb)
}
if (pkg.shipping === 0) computed.push(text.reasonShipFree)
if (guarantee) computed.push(text.reasonGuarantee)
const reasonList = (reasons ?? computed.slice(0, 3)).map((r) => fill(r, vars)).filter((r) => r.trim().length > 0)
const count = text.countWords[reasonList.length - 1] ?? String(reasonList.length)
const reasonsTitle = fill(text.reasonsTitle, { ...vars, count })
const noteFor = (p: SupplyStep, v: Record<string, string>) =>
p.note ?? (p.shipping === 0 ? text.shippingFree : typeof p.shipping === 'number' && p.shipping > 0 ? fill(text.shippingCost, v) : '')
return (
<section className={cx('cf-bp2', disabled && 'is-disabled', className)} style={style} aria-labelledby={titleId}>
<style>{CSS}</style>
<form className='cf-bp2-form' onSubmit={handleSubmit} noValidate>
<div className='cf-bp2-wrap cf-bp2-head'>
<h2 id={titleId} className='cf-bp2-title'>
{withMarker(headline, highlight)}
</h2>
{lead ? <p className='cf-bp2-lead'>{lead}</p> : null}
</div>
<div className='cf-bp2-stage' style={FX_HOST}>
<Pattern name='grid' fade='edges' />
<div className='cf-bp2-wrap cf-bp2-stage-inner'>
<fieldset
className={cx('cf-bp2-stairs', n < 3 && 'is-short')}
style={{ '--n': n } as React.CSSProperties}
disabled={disabled}
>
<legend className='cf-bp2-sr'>{text.legend}</legend>
{text.ladder ? (
<p className='cf-bp2-ladder'>
<TrendingDown size={20} strokeWidth={2.5} aria-hidden />
{fill(text.ladder, vars)}
</p>
) : null}
{packages.map((p, i) => {
const r = rows[i]
const v = varsFor(i)
const isSel = i === index
const note = noteFor(p, v)
const stepStyle = {
'--i': i,
'--back': n - 1 - i,
'--d': `${Math.min(i * 0.07, 0.28)}s`,
gridColumn: i + 1,
} as React.CSSProperties
return (
<label key={p.id ?? `${p.units}-${i}`} className={cx('cf-bp2-step', isSel && 'is-selected')} style={stepStyle}>
<input
className='cf-bp2-radio'
type='radio'
name={group}
value={p.id ?? String(p.units)}
checked={isSel}
disabled={disabled || loading}
onChange={() => choose(i)}
/>
{hasMedia ? (
<span className='cf-bp2-media'>
{p.image ? (
<img
src={p.image}
alt={p.imageAlt ?? (product ? fill(text.imageAlt, v) : '')}
width={512}
height={512}
loading='lazy'
decoding='async'
/>
) : null}
</span>
) : null}
<span className='cf-bp2-block'>
<span className='cf-bp2-cap'>
<span>{fill(text.cap, v)}</span>
{isSel ? (
<span className='cf-bp2-pick'>
<Check size={16} strokeWidth={2.5} aria-hidden />
<span className='cf-bp2-pick-text'>{text.pick}</span>
</span>
) : null}
</span>
<span className='cf-bp2-body'>
{i === bestIndex ? <span className='cf-bp2-flag'>{bestValueLabel}</span> : null}
<span className='cf-bp2-price'>
<span className='cf-bp2-num'>{v.perUnit}</span>
<span className='cf-bp2-per'>{fill(text.perUnit, v)}</span>
</span>
<span className='cf-bp2-total'>{fill(text.packTotal, v)}</span>
{note ? (
<span className='cf-bp2-note'>
<Truck size={16} strokeWidth={2.5} aria-hidden />
{note}
</span>
) : null}
<span className={cx('cf-bp2-foot', r.savings > 0 && 'is-save')}>
<span className='cf-bp2-foot-text'>{fill(r.savings > 0 ? text.saveLine : text.baseLine, v)}</span>
</span>
</span>
</span>
</label>
)
})}
</fieldset>
</div>
</div>
<div className='cf-bp2-wrap cf-bp2-order'>
<div className={cx('cf-bp2-card', reasonList.length === 0 && 'is-solo')}>
{reasonList.length > 0 ? (
<div className='cf-bp2-reasons'>
<h3 className='cf-bp2-h3'>{reasonsTitle}</h3>
<ol className='cf-bp2-list'>
{reasonList.map((reason, k) => (
<li key={k}>
<span className='cf-bp2-n' aria-hidden>
{k + 1}
</span>
<span>{reason}</span>
</li>
))}
</ol>
{pkg.image ? (
<img
key={index}
className='cf-bp2-shot'
src={pkg.image}
alt=''
width={512}
height={512}
loading='lazy'
decoding='async'
/>
) : null}
</div>
) : null}
<div className='cf-bp2-close'>
<dl className='cf-bp2-receipt'>
<div className='cf-bp2-row'>
<dt>
{fill(text.receiptItems, vars)}
{product ? <span className='cf-bp2-sub'>{product}</span> : null}
</dt>
<dd>{vars.compare}</dd>
</div>
{row.savings > 0 ? (
<div className='cf-bp2-row is-discount'>
<dt>{text.receiptDiscount}</dt>
<dd>−{vars.savings}</dd>
</div>
) : null}
{typeof pkg.shipping === 'number' ? (
<div className='cf-bp2-row'>
<dt>{text.receiptShipping}</dt>
<dd>{pkg.shipping === 0 ? text.receiptFree : vars.shipping}</dd>
</div>
) : null}
<div className='cf-bp2-row is-total'>
<dt>{text.receiptTotal}</dt>
<dd>{vars.total}</dd>
</div>
</dl>
<button
type='submit'
className={cx('cf-bp2-button', state === 'hover' && 'is-hover', state === 'active' && 'is-active')}
disabled={disabled || loading}
aria-busy={loading || undefined}
aria-describedby={status === 'error' ? errorId : undefined}
>
{loading ? <Loader2 className='cf-bp2-spin' size={20} strokeWidth={2.5} aria-hidden /> : null}
<span>{loading ? loadingLabel : label}</span>
</button>
{status === 'error' ? (
<p id={errorId} className='cf-bp2-error' role='alert'>
<AlertCircle size={18} strokeWidth={2.5} aria-hidden />
{errorMessage}
</p>
) : null}
{guarantee || secureLabel ? (
<p className='cf-bp2-reassure'>
{guarantee ? (
<span>
<ShieldCheck className='cf-bp2-shield' size={16} strokeWidth={2.5} aria-hidden />
{guarantee}
</span>
) : null}
{secureLabel ? (
<span>
<Lock size={16} strokeWidth={2.5} aria-hidden />
{secureLabel}
</span>
) : null}
</p>
) : null}
</div>
</div>
</div>
<p className='cf-bp2-sr' aria-live='polite'>
{announce}
</p>
</form>
</section>
)
}
export default BundlePicker2
const DEFAULT_PACKAGES: SupplyStep[] = [
{ units: 1, price: 39 },
{ units: 3, price: 99 },
{ units: 6, price: 159 },
]
const DEFAULT_COPY: BundlePicker2Copy = {
legend: 'Choose your supply',
ladder: 'The higher you climb, the less each {unit} costs.',
cap: '{units} {UnitWord}',
pick: 'Your pick',
perUnit: 'per {unit}',
packTotal: '{price} total',
shippingFree: 'Free shipping',
shippingCost: '+ {shipping} shipping',
saveLine: 'Save {savings} vs. single {unitOther}',
baseLine: 'Single-{unit} price',
reasonsTitle: '{count} to take {units} {unitWord} today',
countWords: ['One reason', 'Two reasons', 'Three reasons', 'Four reasons', 'Five reasons'],
reasonDrop: 'Each {unit} drops to {perUnit}, down from {basePer} on its own.',
reasonStart: 'Start small: {units} {unitWord} for {price}.',
reasonClimb: 'Climb to {bestUnits} {bestWord} and each {unit} costs {bestPer}.',
reasonShipFree: 'Shipping is free on this supply.',
reasonGuarantee: 'Backed by the {guarantee}.',
receiptItems: '{units} {unitWord} × {basePer}',
receiptDiscount: 'Supply discount',
receiptShipping: 'Shipping',
receiptFree: 'Free',
receiptTotal: 'Total today',
button: 'Yes! I want {units} {unitWord} · {total}',
live: '{units} {unitWord} selected, {total} total.',
imageAlt: '{units} {unitWord} of {product}',
}
function fill(template: string, vars: Record<string, string>) {
return template.replace(/[{]([A-Za-z]+)[}]/g, (match: string, key: string) => (key in vars ? vars[key] : match))
}
function formatMoney(n: number, locale: string, currency: string) {
const whole = Math.abs(n - Math.round(n)) < 0.005
try {
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
minimumFractionDigits: whole ? 0 : 2,
maximumFractionDigits: whole ? 0 : 2,
}).format(whole ? Math.round(n) : n)
} catch {
return String(n)
}
}
function withMarker(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text
const at = text.indexOf(phrase)
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='cf-bp2-mark'>{phrase}</span>
{text.slice(at + phrase.length)}
</>
)
}
function cx(...parts: Array<string | false | null | undefined>) {
return parts.filter(Boolean).join(' ')
}
const CSS = `
.cf-bp2{--bp2-sh:var(--shadow,oklch(0.22 0.03 260));--bp2-btn:var(--button-bg,var(--cta,oklch(0.58 0.21 29)));--bp2-btn-2:var(--button-bg-2,var(--cta-2,oklch(0.51 0.21 29)));--bp2-md:var(--shadow-md,0 1px 2px oklch(from var(--bp2-sh) l c h / .22),0 4px 10px -2px oklch(from var(--bp2-sh) l c h / .2));--bp2-lg:var(--shadow-lg,0 2px 4px oklch(from var(--bp2-sh) l c h / .22),0 12px 24px -8px oklch(from var(--bp2-sh) l c h / .32));--bp2-border:var(--card-border,oklch(from var(--ink,oklch(0.21 0.03 263)) l c h / .12));--bp2-radius:var(--card-radius,var(--radius,14px));--bp2-btn-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--bp2-btn) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--bp2-btn) calc(l - .16) c h),0 1px 2px oklch(from var(--bp2-sh) l c h / .3),0 8px 16px -6px oklch(from var(--bp2-sh) l c h / .45));background:var(--surface,oklch(1 0 0));color:var(--ink,oklch(0.21 0.03 263));font-family:var(--font-body,system-ui,sans-serif);padding-block:clamp(56px,8vw,112px) clamp(64px,8.5vw,120px);overflow-x:clip}
.cf-bp2 *,.cf-bp2 *::before,.cf-bp2 *::after{box-sizing:border-box}
.cf-bp2-form{margin:0}
.cf-bp2-wrap{width:100%;max-width:calc(1120px + 2 * clamp(16px,5vw,48px));margin-inline:auto;padding-inline:clamp(16px,5vw,48px)}
.cf-bp2-sr,.cf-bp2-radio{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.cf-bp2-head{text-align:center}
.cf-bp2-title{max-width:46rem;margin:0 auto;font-family:var(--font-display,inherit);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;color:var(--ink,oklch(0.21 0.03 263));text-wrap:balance}
.cf-bp2-mark{background-image:linear-gradient(100deg,transparent .2em,var(--marker,#fae37c) .2em,var(--marker,#fae37c) calc(100% - .2em),transparent calc(100% - .2em));background-repeat:no-repeat;background-size:100% 62%;background-position:0 88%;padding-inline:.14em;margin-inline:-.06em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-bp2-lead{max-width:40rem;margin:clamp(14px,1.4vw,18px) auto 0;font-size:clamp(1.125rem,1.5vw,1.375rem);font-weight:500;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));text-wrap:pretty}
.cf-bp2-stage{position:relative;isolation:isolate;overflow:hidden;margin-top:clamp(32px,4vw,48px);padding-top:clamp(40px,5vw,64px);background:var(--band,oklch(0.27 0.07 256));color:var(--band-ink,oklch(1 0 0))}
.cf-bp2-stage-inner{position:relative;z-index:1}
.cf-bp2-stairs{--step-h:320px;--rise:56px;margin:0;padding:0;border:0;min-width:0;display:grid;grid-template-columns:repeat(var(--n,3),minmax(0,1fr));gap:clamp(12px,2vw,24px);align-items:end}
.cf-bp2-ladder{grid-row:1;grid-column:1;align-self:start;position:relative;z-index:2;max-width:22rem;margin:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:700;line-height:1.4;color:var(--band-ink,oklch(1 0 0));text-wrap:pretty}
.cf-bp2-ladder svg,.cf-bp2-note svg,.cf-bp2-reassure svg,.cf-bp2-error svg{display:inline-block;vertical-align:-0.15em;margin-inline-end:.4em}
.cf-bp2-stairs.is-short .cf-bp2-ladder{grid-column:1/-1;margin-bottom:24px}
.cf-bp2-stairs.is-short .cf-bp2-step{grid-row:2}
.cf-bp2-step{grid-row:1;position:relative;display:flex;flex-direction:column;min-width:0;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:translate .22s cubic-bezier(.2,.7,.2,1);animation:cf-bp2-rise .45s cubic-bezier(.2,.7,.2,1) both;animation-delay:var(--d,0s)}
.cf-bp2-media{display:flex;align-items:flex-end;justify-content:center;height:clamp(130px,13vw,184px);padding-inline:4%}
.cf-bp2-media img{display:block;width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;object-position:50% 100%;filter:drop-shadow(0 2px 3px oklch(from var(--bp2-sh) l c h / .45)) drop-shadow(0 10px 12px oklch(from var(--bp2-sh) l c h / .35))}
.cf-bp2-block{position:relative;display:flex;flex-direction:column;min-height:calc(var(--step-h) + var(--i,0) * var(--rise));background:var(--card,oklch(1 0 0));color:var(--ink,oklch(0.21 0.03 263));border:1px solid var(--bp2-border);border-bottom:0;border-radius:var(--bp2-radius) var(--bp2-radius) 0 0;box-shadow:var(--bp2-md);overflow:hidden;transition:box-shadow .22s ease}
.cf-bp2-cap{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;min-height:56px;padding:12px clamp(16px,2vw,24px);background:color-mix(in oklch,var(--ink,oklch(0.21 0.03 263)) 6%,var(--card,oklch(1 0 0)));font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;transition:background .16s ease,color .16s ease}
.cf-bp2-pick{display:inline-flex;align-items:center;gap:6px;font-family:var(--font-body,inherit);font-size:.875rem;font-weight:800;line-height:1.2;letter-spacing:.02em;white-space:nowrap}
.cf-bp2-step.is-selected{z-index:1}
.cf-bp2-media img{transition:translate .22s cubic-bezier(.2,.7,.2,1)}
.cf-bp2-step.is-selected .cf-bp2-media img{translate:0 -8px}
.cf-bp2-step.is-selected .cf-bp2-block{box-shadow:0 0 0 2px var(--bp2-btn),var(--bp2-lg)}
.cf-bp2-step.is-selected .cf-bp2-cap{background:linear-gradient(oklch(from var(--bp2-btn) calc(l + .04) c h),oklch(from var(--bp2-btn-2) calc(l - .02) c h));color:var(--button-ink,var(--cta-ink,oklch(1 0 0)));text-shadow:var(--button-text-shadow,none)}
@media (hover:hover){
.cf-bp2:not(.is-disabled) .cf-bp2-step:not(.is-selected):hover .cf-bp2-media img{translate:0 -4px}
.cf-bp2:not(.is-disabled) .cf-bp2-step:not(.is-selected):hover .cf-bp2-block{box-shadow:var(--bp2-lg)}
.cf-bp2:not(.is-disabled) .cf-bp2-step:not(.is-selected):hover .cf-bp2-cap{background:color-mix(in oklch,var(--ink,oklch(0.21 0.03 263)) 11%,var(--card,oklch(1 0 0)))}
}
.cf-bp2-step:has(.cf-bp2-radio:focus-visible) .cf-bp2-block{outline:3px solid var(--band-ink,oklch(1 0 0));outline-offset:4px}
.cf-bp2.is-disabled .cf-bp2-step{cursor:not-allowed}
.cf-bp2.is-disabled .cf-bp2-media img{opacity:.7}
.cf-bp2.is-disabled .cf-bp2-step.is-selected .cf-bp2-cap{background:var(--secondary,color-mix(in oklch,var(--ink,oklch(0.21 0.03 263)) 10%,var(--card,oklch(1 0 0))));color:var(--secondary-ink,var(--ink,oklch(0.21 0.03 263)));text-shadow:none}
.cf-bp2.is-disabled .cf-bp2-step.is-selected .cf-bp2-block{box-shadow:var(--bp2-md)}
.cf-bp2-body{display:flex;flex:1;flex-direction:column;align-items:flex-start;padding:clamp(18px,2.2vw,26px) clamp(16px,2vw,24px) clamp(18px,2.2vw,24px)}
.cf-bp2-flag{display:inline-flex;align-items:center;min-height:28px;margin-bottom:14px;padding:4px 12px;border-radius:999px;background:var(--accent-fill,var(--accent,oklch(0.5 0.17 257)));color:var(--accent-fill-ink,var(--card,oklch(1 0 0)));font-size:.875rem;font-weight:800;line-height:1.2;letter-spacing:.04em;text-transform:uppercase;white-space:nowrap;animation:cf-bp2-pop .3s ease both}
.cf-bp2-price{display:flex;flex-direction:column}
.cf-bp2-num{font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;letter-spacing:-0.03em;font-variant-numeric:tabular-nums}
.cf-bp2-per{margin-top:12px;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258))}
.cf-bp2-total{margin-top:16px;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:700;line-height:1.4;font-variant-numeric:tabular-nums}
.cf-bp2-note{margin-top:4px;font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));text-wrap:pretty}
.cf-bp2-foot{margin-top:auto;padding-top:16px;font-size:.9375rem;font-weight:700;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));text-wrap:pretty}
.cf-bp2-foot.is-save{color:var(--success,oklch(0.5 0.14 150))}
@media (min-width:900px){.cf-bp2-foot.is-save .cf-bp2-foot-text{display:inline-block;padding:5px 12px;border-radius:999px;background:var(--success-soft,oklch(0.93 0.019 150));font-size:.875rem;font-weight:800;line-height:1.3}}
.cf-bp2-shot{display:block;height:clamp(140px,14vw,184px);width:auto;max-width:100%;margin-top:clamp(24px,3vw,32px);object-fit:contain;object-position:0 100%;filter:drop-shadow(0 2px 3px oklch(from var(--bp2-sh) l c h / .3)) drop-shadow(0 10px 12px oklch(from var(--bp2-sh) l c h / .22));animation:cf-bp2-rise .45s cubic-bezier(.2,.7,.2,1) both}
@media (max-width:899px){.cf-bp2-shot{display:none}}
.cf-bp2-order{margin-top:clamp(40px,5vw,64px)}
.cf-bp2-card{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);gap:clamp(32px,5vw,64px);align-items:start;padding:clamp(20px,3.4vw,40px);background:var(--card,oklch(1 0 0));color:var(--ink,oklch(0.21 0.03 263));border:1px solid var(--bp2-border);border-radius:var(--bp2-radius);box-shadow:var(--bp2-md)}
.cf-bp2-card.is-solo{grid-template-columns:minmax(0,1fr);max-width:36rem;margin-inline:auto}
.cf-bp2-h3{margin:0;font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance}
.cf-bp2-list{list-style:none;margin:20px 0 0;padding:0;display:grid;gap:16px}
.cf-bp2-list li{display:grid;grid-template-columns:2rem minmax(0,1fr);gap:12px;align-items:baseline;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;text-wrap:pretty}
.cf-bp2-n{font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1;color:var(--accent,oklch(0.5 0.17 257));font-variant-numeric:tabular-nums}
.cf-bp2-receipt{display:grid;gap:12px;margin:0;padding:clamp(18px,2.2vw,24px);border-radius:10px;background:color-mix(in oklch,var(--ink,oklch(0.21 0.03 263)) 4%,var(--card,oklch(1 0 0)));font-variant-numeric:tabular-nums}
.cf-bp2-row{display:flex;align-items:baseline;justify-content:space-between;gap:16px}
.cf-bp2-row dt{min-width:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:600;line-height:1.4}
.cf-bp2-row dd{margin:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:700;line-height:1.4;white-space:nowrap}
.cf-bp2-sub{display:block;margin-top:2px;font-size:.9375rem;font-weight:500;color:var(--muted,oklch(0.45 0.03 258))}
.cf-bp2-row.is-discount dd{color:var(--success,oklch(0.5 0.14 150))}
.cf-bp2-row.is-total{margin-top:12px;align-items:flex-end}
.cf-bp2-row.is-total dt{font-weight:800}
.cf-bp2-row.is-total dd{font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;letter-spacing:-0.03em}
.cf-bp2-button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:72px;margin-top:24px;padding:12px 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from var(--bp2-btn) calc(l + .04) c h),oklch(from var(--bp2-btn-2) calc(l - .02) c h));color:var(--button-ink,var(--cta-ink,oklch(1 0 0)));font-family:var(--button-font,var(--font-display,inherit));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(--bp2-btn-shadow);transition:background .16s ease,box-shadow .16s ease,transform .16s ease}
.cf-bp2-button:hover:not(:disabled),.cf-bp2-button.is-hover:not(:disabled){background:linear-gradient(oklch(from var(--bp2-btn) calc(l - .01) c h),oklch(from var(--bp2-btn-2) calc(l - .07) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--bp2-btn) calc(l + .1) c h / .6),inset 0 -3px 0 oklch(from var(--bp2-btn) calc(l - .2) c h),0 1px 2px oklch(from var(--bp2-sh) l c h / .32),0 10px 18px -6px oklch(from var(--bp2-sh) l c h / .52))}
.cf-bp2-button:active:not(:disabled),.cf-bp2-button.is-active:not(:disabled){transform:translateY(1px);background:linear-gradient(oklch(from var(--bp2-btn) calc(l - .04) c h),oklch(from var(--bp2-btn-2) calc(l - .08) c h));box-shadow:inset 0 2px 4px oklch(from var(--bp2-btn) calc(l - .24) c h / .5),inset 0 -2px 0 oklch(from var(--bp2-btn) calc(l - .18) c h),0 1px 2px oklch(from var(--bp2-sh) l c h / .3)}
.cf-bp2-button:focus-visible{outline:3px solid var(--field-focus,var(--accent,oklch(0.5 0.17 257)));outline-offset:3px}
.cf-bp2-button:disabled{cursor:not-allowed;background:var(--button-2-bg,var(--secondary,oklch(0.93 0.015 263)));color:var(--button-2-ink,var(--secondary-ink,oklch(0.21 0.03 263)));text-shadow:none;box-shadow:var(--button-2-shadow,var(--shadow-sm,0 1px 2px oklch(from var(--bp2-sh) l c h / .2)))}
.cf-bp2-button[aria-busy='true']:disabled{cursor:progress;background:linear-gradient(oklch(from var(--bp2-btn) calc(l + .04) c h),oklch(from var(--bp2-btn-2) calc(l - .02) c h));color:var(--button-ink,var(--cta-ink,oklch(1 0 0)));text-shadow:var(--button-text-shadow,none);box-shadow:var(--bp2-btn-shadow)}
.cf-bp2-spin{flex:none;animation:cf-bp2-spin .8s linear infinite}
.cf-bp2-error{margin:14px 0 0;padding:12px 16px;border-radius:10px;background:var(--danger-soft,oklch(0.93 0.024 27));color:var(--danger,oklch(0.5 0.17 27));font-size:.9375rem;font-weight:600;line-height:1.4;text-wrap:pretty}
.cf-bp2-reassure{margin:14px 0 0;text-align:center;font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted,oklch(0.45 0.03 258));text-wrap:pretty}
.cf-bp2-reassure > span{white-space:nowrap}
.cf-bp2-reassure > span + span::before{content:'·';margin-inline:.6em}
.cf-bp2-shield{color:var(--success,oklch(0.5 0.14 150))}
@keyframes cf-bp2-rise{from{opacity:.82;transform:translateY(8px)}}
@keyframes cf-bp2-pop{from{transform:scale(.9)}}
@keyframes cf-bp2-spin{to{transform:rotate(360deg)}}
@media (max-width:1023px){.cf-bp2-stairs{--step-h:340px;--rise:52px}}
@media (max-width:899px){.cf-bp2-card{grid-template-columns:minmax(0,1fr)}}
@media (min-width:640px) and (max-width:899px){.cf-bp2-pick-text{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}}
@media (max-width:639px){
.cf-bp2-stage{padding-top:28px;padding-bottom:32px}
.cf-bp2-stairs{display:flex;flex-direction:column;align-items:flex-start;gap:12px}
.cf-bp2-ladder{max-width:none;margin-bottom:4px}
.cf-bp2-step{width:calc(100% - var(--back,0) * 6%);display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:'cap cap' 'media body';background:var(--card,oklch(1 0 0));color:var(--ink,oklch(0.21 0.03 263));border:1px solid var(--bp2-border);border-radius:var(--bp2-radius);box-shadow:var(--bp2-md);overflow:hidden;transition:translate .22s cubic-bezier(.2,.7,.2,1),box-shadow .22s ease}
.cf-bp2-block{display:contents}
.cf-bp2-cap{grid-area:cap;min-height:48px;padding:10px 16px}
.cf-bp2-media{grid-area:media;align-self:center;width:84px;height:84px;margin:14px 0 14px 14px;padding:0;align-items:center}
.cf-bp2-body{grid-area:body;padding:14px 16px 16px 14px}
.cf-bp2-flag{margin-bottom:10px}
.cf-bp2-price{flex-direction:row;flex-wrap:wrap;align-items:baseline;column-gap:8px}
.cf-bp2-num{font-size:2.25rem}
.cf-bp2-per{margin-top:0}
.cf-bp2-total{margin-top:8px}
.cf-bp2-foot{margin-top:8px;padding-top:0}
.cf-bp2-step.is-selected{translate:0 -3px;box-shadow:0 0 0 2px var(--bp2-btn),var(--bp2-lg)}
.cf-bp2.is-disabled .cf-bp2-step.is-selected{box-shadow:var(--bp2-md)}
.cf-bp2:not(.is-disabled) .cf-bp2-step:not(.is-selected):hover{translate:0 -2px}
.cf-bp2-step:has(.cf-bp2-radio:focus-visible){outline:3px solid var(--band-ink,oklch(1 0 0));outline-offset:4px}
.cf-bp2-button{padding:12px 20px}
.cf-bp2-step.is-selected .cf-bp2-media img,.cf-bp2:not(.is-disabled) .cf-bp2-step:not(.is-selected):hover .cf-bp2-media img{translate:none}
.cf-bp2-reassure > span{display:block}
.cf-bp2-reassure > span + span{margin-top:4px}
.cf-bp2-reassure > span + span::before{content:none}
}
@media (prefers-reduced-motion:reduce){
.cf-bp2-step,.cf-bp2-flag,.cf-bp2-spin,.cf-bp2-shot{animation:none}
.cf-bp2-step,.cf-bp2-block,.cf-bp2-cap,.cf-bp2-button,.cf-bp2-media img{transition:none}
}
`
pieces/offer/bundle-picker-2/specimen.tsx 58 lines
import __studioImage7ec7ddd9 from "../assets/1d08453f8c0b9a76.webp";
import __studioImage1711f9e3 from "../assets/79e007f5441a22ce.webp";
import __studioImageb4416442 from "../assets/d66f14f3030dc297.webp";
import * as React from 'react'
import { BundlePicker2, type BundlePicker2State } from '../bundle-picker-2'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function BundlePicker2Specimen({ state }: { state?: BundlePicker2State }) {
return (
<BundlePicker2
state={state}
headline='Stock up on Coastline and pay less for every jar'
highlight='pay less for every jar'
lead='Coastline Magnesium Glycinate comes in 1, 3 and 6 jar supplies. Every step up the staircase lowers what you pay per jar.'
product='Coastline Magnesium Glycinate'
unit={{ one: 'Jar', other: 'Jars' }}
guarantee={defaults.sample.guarantee}
packages={[
{
units: 1,
price: 39,
shipping: 6.95,
id: 'coastline-1',
imageAlt: 'One jar of Coastline Magnesium Glycinate',
image: slot(
'item-1',
__studioImage7ec7ddd9
),
},
{
units: 3,
price: 99,
shipping: 0,
id: 'coastline-3',
imageAlt: 'Three jars of Coastline Magnesium Glycinate',
image: slot(
'item-2',
__studioImage1711f9e3
),
},
{
units: 6,
price: 159,
shipping: 0,
id: 'coastline-6',
imageAlt: 'Six jars of Coastline Magnesium Glycinate',
image: slot(
'item-3',
__studioImageb4416442
),
},
]}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalBundlePicker2 |
string |
|
highlight OptionalBundlePicker2 |
string |
|
lead OptionalBundlePicker2 |
string |
|
product OptionalBundlePicker2 |
string |
|
packages OptionalBundlePicker2 |
SupplyStep[] |
|
unit OptionalBundlePicker2 |
{ one: string; other: string } |
|
defaultSelected OptionalBundlePicker2 |
number |
|
currency OptionalBundlePicker2 |
string |
|
locale OptionalBundlePicker2 |
string |
|
buttonLabel OptionalBundlePicker2 |
string | ((ctx: BundlePicker2Context) => string) |
|
loadingLabel OptionalBundlePicker2 |
string |
|
bestValueLabel OptionalBundlePicker2 |
string |
|
guarantee OptionalBundlePicker2 |
string |
|
secureLabel OptionalBundlePicker2 |
string |
|
errorMessage OptionalBundlePicker2 |
string |
|
reasons OptionalBundlePicker2 |
string[] |
|
state OptionalBundlePicker2 |
BundlePicker2State |
|
onSelect OptionalBundlePicker2 |
(pkg: SupplyStep, index: number) => void |
|
onSubmit OptionalBundlePicker2 |
(pkg: SupplyStep, index: number) => void | Promise<void> |
|
copy OptionalBundlePicker2 |
Partial<BundlePicker2Copy> |
|
className OptionalBundlePicker2 |
string |
|
style OptionalBundlePicker2 |
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--button-2-shadow- Secondary button.
--card-border--card-radius- 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.
-
1d08453f8c0b9a76.webp
image/webp · 47.7 KB
-
79e007f5441a22ce.webp
image/webp · 92.4 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
d66f14f3030dc297.webp
image/webp · 86.2 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB