Product Buy Box 2
Product-page front: masthead, dateline and story columns beside a one-time vs subscribe-and-save buy column. Switching tiles re-prices the hang tag and the two-line button live; phones get a sticky price bar.
Use it in a prompt
Use offer/product-buy-box-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/product-buy-box-2.tsx. - Import it and pass your copy and images (Props tab):
import { ProductBuyBox2 } from "@/components/funneldna/offer/product-buy-box-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/product-buy-box-2/component.tsx 675 lines
// layout: advertorial-front
// Product-page front: masthead, dateline and story columns beside a one-time vs subscribe-and-save buy column. Switching tiles re-prices the hang tag and the two-line button live; phones get a sticky price bar.
'use client'
import * as React from 'react'
import { AlertCircle, Check, ChevronDown, Minus, Plus, RotateCcw, ShieldCheck } from 'lucide-react'
export type CadenceOption = { value: string; label: string }
export type ProductBuyBox2Plan = 'one-time' | 'subscribe'
export type ProductBuyBox2Order = { plan: ProductBuyBox2Plan; cadence?: string; quantity: number }
export type ProductBuyBox2State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
export type ProductBuyBox2Subscription = {
/** Price per unit for each delivery when subscribed. */
price: string
/** Supplied discount flag, e.g. Save 15%. Never computed. */
badge?: string
/** One supplied line on why subscribing costs less. */
reasonWhy?: string
/** A phrase inside reasonWhy swiped with the marker. */
reasonHighlight?: string
/** Delivery cadences; the select shows only on the subscribe tile. */
cadences: CadenceOption[]
defaultCadence?: string
/** Supplied skip / move / cancel terms. */
terms?: string
}
export type ProductBuyBox2Copy = {
choiceHeading: string
/** Heading when there is no subscription. */
choiceHeadingOneTime: string
groupLabel: string
oneTimeTitle: string
subscribeTitle: string
/** Unit after a price, e.g. per bag. */
perUnit: string
/** Unit line under the subscribed price on the tag. */
perUnitSubscribe: string
/** {price} */
wasLabel: string
/** {quantity}, {price}, {total} */
totalOneTime: string
/** {quantity}, {price}, {total} */
totalSubscribe: string
quantityLabel: string
decrease: string
increase: string
cadenceLabel: string
cadencePlaceholder: string
cadenceError: string
/** The plain instruction above the button. */
instruction: string
label: string
/** {total} */
sublineOneTime: string
/** {cadence}, {total} */
sublineSubscribe: string
sublineNoCadence: string
barOneTime: string
/** {cadence} */
barSubscribe: string
barNoCadence: string
barButton: string
disabledNote: string
}
export type ProductBuyBox2Props = {
/** Brand or product name set as the front-page masthead. */
masthead: string
/** Short facts in the dateline under the masthead. */
dateline?: string[]
headline: React.ReactNode
lead?: string
/** product slot: cut-out on a transparent background. */
productImage?: string
productImageAlt?: string
productCaption?: string
/** scene slot: photo for the story column. */
sceneImage?: string
sceneImageAlt?: string
sceneCaption?: string
story?: string[]
oneTime: { price: string; note?: string }
/** Omit for the one-time-only variant. */
subscription?: ProductBuyBox2Subscription
defaultPlan?: ProductBuyBox2Plan
quantity?: { min?: number; max?: number; initial?: number }
/** One reassurance line under the button (supplied). */
assurance?: string
disabled?: boolean
state?: ProductBuyBox2State
copy?: Partial<ProductBuyBox2Copy>
/** Called with the validated choice. */
onSubmit?: (order: ProductBuyBox2Order) => void
/** Called on a valid submit when there is no onSubmit. */
onAction?: () => void
/** Where a valid submit goes when there is no onSubmit or onAction. */
href?: string
className?: string
}
const DEFAULT_COPY: ProductBuyBox2Copy = {
choiceHeading: 'Buy it once, or never run out',
choiceHeadingOneTime: 'Get yours today',
groupLabel: 'Choose how you buy',
oneTimeTitle: 'One-time purchase',
subscribeTitle: 'Subscribe & save',
perUnit: 'each',
perUnitSubscribe: 'each, every delivery',
wasLabel: 'One-time price {price}',
totalOneTime: '{quantity} × {price} = {total} today',
totalSubscribe: '{quantity} × {price} = {total} per delivery',
quantityLabel: 'Quantity',
decrease: 'Decrease quantity',
increase: 'Increase quantity',
cadenceLabel: 'Delivery schedule',
cadencePlaceholder: 'Choose how often…',
cadenceError: 'Choose how often you want it delivered.',
instruction: 'Click the button below to add it to your cart.',
label: 'Add to cart',
sublineOneTime: 'One-time purchase · {total}',
sublineSubscribe: 'Subscribe · {cadence} · {total}/delivery',
sublineNoCadence: 'Subscribe · choose your delivery schedule',
barOneTime: 'One-time purchase',
barSubscribe: 'Subscribe · {cadence}',
barNoCadence: 'Subscribe · choose a schedule',
barButton: 'Add to cart',
disabledNote: 'This product isn’t available right now.',
}
export function ProductBuyBox2({
masthead,
dateline = [],
headline,
lead,
productImage,
productImageAlt = '',
productCaption,
sceneImage,
sceneImageAlt = '',
sceneCaption,
story = [],
oneTime,
subscription,
defaultPlan,
quantity,
assurance,
disabled = false,
state = 'default',
copy,
onSubmit,
onAction,
href,
className = '',
}: ProductBuyBox2Props) {
const t = { ...DEFAULT_COPY, ...copy }
const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, '')
const formId = `${uid}-form`
const hasSub = !!subscription && subscription.cadences.length > 0
const isDisabled = disabled || state === 'disabled'
const force = state === 'hover' || state === 'active' ? state : undefined
const min = Math.max(1, quantity?.min ?? 1)
const max = Math.max(min, quantity?.max ?? 12)
const startQty = clamp(quantity?.initial ?? min, min, max)
const startPlan: ProductBuyBox2Plan =
hasSub && (state === 'error' || (defaultPlan ?? 'subscribe') === 'subscribe') ? 'subscribe' : 'one-time'
const startCadence = state === 'error' ? '' : subscription?.defaultCadence ?? ''
const [plan, setPlan] = React.useState<ProductBuyBox2Plan>(startPlan)
const [cadence, setCadence] = React.useState(startCadence)
const [qty, setQty] = React.useState(startQty)
const [error, setError] = React.useState<string | null>(state === 'error' && hasSub ? t.cadenceError : null)
const [barHidden, setBarHidden] = React.useState(false)
const selectRef = React.useRef<HTMLSelectElement>(null)
const mainRef = React.useRef<HTMLButtonElement>(null)
React.useEffect(() => {
setPlan(startPlan)
setCadence(startCadence)
setQty(startQty)
setError(state === 'error' && hasSub ? t.cadenceError : null)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
React.useEffect(() => {
const el = mainRef.current
if (!el || typeof IntersectionObserver === 'undefined') return
const io = new IntersectionObserver(([entry]) => setBarHidden(entry.isIntersecting), { threshold: 0.25 })
io.observe(el)
return () => io.disconnect()
}, [])
const isSub = hasSub && plan === 'subscribe'
const unitPrice = isSub && subscription ? subscription.price : oneTime.price
const unit = parseMoney(unitPrice)
const total = unit != null ? fmtLike(unit * qty, unitPrice) : unitPrice
const oneNum = parseMoney(oneTime.price)
const showWas = isSub && unit != null && oneNum != null && oneNum > unit
const cadenceLabel = subscription?.cadences.find((c) => c.value === cadence)?.label
const subline = !isSub
? fill(t.sublineOneTime, { total })
: cadenceLabel
? fill(t.sublineSubscribe, { cadence: cadenceLabel, total })
: t.sublineNoCadence
const barChoice = !isSub ? t.barOneTime : cadenceLabel ? fill(t.barSubscribe, { cadence: cadenceLabel }) : t.barNoCadence
const perLine =
qty > 1 && unit != null
? fill(isSub ? t.totalSubscribe : t.totalOneTime, { quantity: qty, price: unitPrice, total })
: isSub
? t.perUnitSubscribe
: t.perUnit
const errId = `${uid}-err`
function choose(next: ProductBuyBox2Plan) {
if (isDisabled) return
setPlan(next)
if (next === 'one-time') setError(null)
}
function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault()
if (isDisabled) return
if (isSub && !cadence) {
setError(t.cadenceError)
selectRef.current?.focus()
return
}
setError(null)
const order: ProductBuyBox2Order = isSub
? { plan: 'subscribe', cadence, quantity: qty }
: { plan: 'one-time', quantity: qty }
if (onSubmit) onSubmit(order)
else if (onAction) onAction()
else if (href) window.location.assign(href)
}
return (
<section className={`cf-pbb2 ${className}`.trim()} aria-labelledby={`${uid}-h`}>
<style>{CSS}</style>
<div className='inner'>
<div className='mast'>
<p className='mast-name'>{masthead}</p>
{dateline.length > 0 && (
<ul className='dateline'>
{dateline.map((d) => (
<li key={d}>{d}</li>
))}
</ul>
)}
</div>
<div className='front'>
<header className='lede'>
<h2 id={`${uid}-h`} className='headline'>
{headline}
</h2>
{lead && <p className='lead'>{lead}</p>}
</header>
{productImage && (
<figure className='product'>
<img src={productImage} alt={productImageAlt} width={640} height={640} />
{productCaption && <figcaption>{productCaption}</figcaption>}
</figure>
)}
{(sceneImage || story.length > 0) && (
<div className='story'>
{sceneImage && (
<figure className='scene'>
<img src={sceneImage} alt={sceneImageAlt} width={960} height={720} loading='lazy' />
{sceneCaption && <figcaption>{sceneCaption}</figcaption>}
</figure>
)}
{story.map((p, i) => (
<p key={i}>{p}</p>
))}
</div>
)}
<form id={formId} className='buy' onSubmit={handleSubmit} noValidate aria-labelledby={`${uid}-buy`}>
<h3 id={`${uid}-buy`} className='buy-h'>
{hasSub ? t.choiceHeading : t.choiceHeadingOneTime}
</h3>
<fieldset className='choices' disabled={isDisabled}>
<legend className='sr'>{t.groupLabel}</legend>
<div className='tile' data-selected={!isSub ? '' : undefined} data-disabled={isDisabled ? '' : undefined}>
<label className='tile-hit' htmlFor={`${uid}-one`}>
<input
id={`${uid}-one`}
className='radio'
type='radio'
name={`${uid}-plan`}
value='one-time'
checked={!isSub}
onChange={() => choose('one-time')}
/>
<span className='dot' aria-hidden='true'>
<Check size={16} strokeWidth={3} />
</span>
<span className='tile-head'>
<span className='tile-title'>{t.oneTimeTitle}</span>
{oneTime.note && <span className='tile-note'>{oneTime.note}</span>}
</span>
<span className='tile-price'>
<span className='tile-num'>{oneTime.price}</span>
<span className='tile-per'>{t.perUnit}</span>
</span>
</label>
</div>
{hasSub && subscription && (
<div className='tile' data-selected={isSub ? '' : undefined} data-disabled={isDisabled ? '' : undefined}>
<label className='tile-hit' htmlFor={`${uid}-sub`}>
<input
id={`${uid}-sub`}
className='radio'
type='radio'
name={`${uid}-plan`}
value='subscribe'
checked={isSub}
onChange={() => choose('subscribe')}
/>
<span className='dot' aria-hidden='true'>
<Check size={16} strokeWidth={3} />
</span>
<span className='tile-head'>
<span className='tile-title-row'>
<span className='tile-title'>{t.subscribeTitle}</span>
{subscription.badge && <span className='flag'>{subscription.badge}</span>}
</span>
</span>
<span className='tile-price'>
<span className='tile-num'>{subscription.price}</span>
<span className='tile-per'>{t.perUnit}</span>
</span>
{subscription.reasonWhy && (
<span className='tile-reason'>{highlight(subscription.reasonWhy, subscription.reasonHighlight)}</span>
)}
</label>
{isSub && (
<div className='tile-more'>
<label className='field-label' htmlFor={`${uid}-cad`}>
{t.cadenceLabel}
</label>
<div className='select-wrap'>
<select
id={`${uid}-cad`}
ref={selectRef}
value={cadence}
required
aria-invalid={error ? true : undefined}
aria-describedby={error ? errId : undefined}
onChange={(e) => {
setCadence(e.target.value)
if (e.target.value) setError(null)
}}
>
<option value='' disabled>
{t.cadencePlaceholder}
</option>
{subscription.cadences.map((c) => (
<option key={c.value} value={c.value}>
{c.label}
</option>
))}
</select>
<ChevronDown size={20} strokeWidth={2.5} aria-hidden='true' />
</div>
{error && (
<p className='field-error' id={errId} role='alert'>
<AlertCircle className='ico' size={16} strokeWidth={2.5} aria-hidden='true' />
{error}
</p>
)}
{subscription.terms && (
<p className='tile-terms'>
<RotateCcw className='ico' size={16} strokeWidth={2.5} aria-hidden='true' />
{subscription.terms}
</p>
)}
</div>
)}
</div>
)}
</fieldset>
<div className='qty'>
<span className='qty-label' id={`${uid}-qty`}>
{t.quantityLabel}
</span>
<div className='stepper' role='group' aria-labelledby={`${uid}-qty`}>
<button
type='button'
className='step'
aria-label={t.decrease}
disabled={isDisabled || qty <= min}
onClick={() => setQty((q) => clamp(q - 1, min, max))}
>
<Minus size={18} strokeWidth={2.5} aria-hidden='true' />
</button>
<output className='qty-val' aria-live='polite'>
{qty}
</output>
<button
type='button'
className='step'
aria-label={t.increase}
disabled={isDisabled || qty >= max}
onClick={() => setQty((q) => clamp(q + 1, min, max))}
>
<Plus size={18} strokeWidth={2.5} aria-hidden='true' />
</button>
</div>
</div>
<div className='tag' aria-live='polite' aria-atomic='true'>
{showWas && (
<p className='tag-was-line'>
<s className='tag-was'>
<span className='sr'>{fill(t.wasLabel, { price: oneTime.price })}</span>
<span aria-hidden='true'>{oneTime.price}</span>
</s>
{subscription?.badge && <span className='tag-save'>{subscription.badge}</span>}
</p>
)}
<p className='tag-price'>
<span key={unitPrice} className='tag-now'>
{unitPrice}
</span>
</p>
<p className='tag-per'>{perLine}</p>
</div>
{isDisabled ? (
<p className='note'>
<AlertCircle className='ico' size={16} strokeWidth={2.5} aria-hidden='true' />
{t.disabledNote}
</p>
) : (
<p className='instruction'>{t.instruction}</p>
)}
<button ref={mainRef} type='submit' className='btn btn-main' disabled={isDisabled} data-force={force}>
<span className='btn-label'>{t.label}</span>
<span className='btn-sub'>{segments(subline)}</span>
</button>
{assurance && (
<p className='assure'>
<ShieldCheck className='ico' size={16} strokeWidth={2.5} aria-hidden='true' />
{assurance}
</p>
)}
</form>
</div>
<div className='bar' data-hidden={barHidden ? '' : undefined} aria-hidden={barHidden ? true : undefined}>
<div className='bar-info'>
<span className='bar-choice'>{barChoice}</span>
<span className='bar-price'>{total}</span>
</div>
<button type='submit' form={formId} className='btn btn-bar' disabled={isDisabled} data-force={force}>
{t.barButton}
</button>
</div>
</div>
</section>
)
}
export default ProductBuyBox2
function clamp(n: number, lo: number, hi: number) {
return Math.min(hi, Math.max(lo, n))
}
function fill(tpl: string, vars: Record<string, string | number>) {
return tpl.replace(/[{]([a-zA-Z]+)[}]/g, (m: string, k: string) => (k in vars ? String(vars[k]) : m))
}
function parseMoney(s?: string) {
if (!s) return null
const n = parseFloat(s.replace(/[^0-9.]/g, ''))
return Number.isFinite(n) ? n : null
}
function fmtLike(n: number, sample: string) {
const digits = sample.replace(/[^0-9.]/g, '')
const dot = digits.indexOf('.')
let dec = dot >= 0 ? digits.length - dot - 1 : 0
if (dec === 0 && !Number.isInteger(n)) dec = 2
const num = n.toLocaleString('en-US', { minimumFractionDigits: dec, maximumFractionDigits: dec })
return sample.replace(/[0-9][0-9,.]*/, num)
}
/** Keeps each " · " segment of a sub-line whole, so phones wrap between segments, never inside one. */
function segments(text: string): React.ReactNode {
const parts = text.split(' · ')
if (parts.length < 2) return text
return parts.map((part, i) => (
<React.Fragment key={i}>
{i > 0 && ' · '}
<span className='nb'>{part}</span>
</React.Fragment>
))
}
function highlight(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text
const i = text.indexOf(phrase)
if (i < 0) return text
return (
<>
{text.slice(0, i)}
<mark>{phrase}</mark>
{text.slice(i + phrase.length)}
</>
)
}
const CSS = `
.cf-pbb2{
--pbb2-gutter:clamp(16px,5vw,48px);
--pbb2-hair:oklch(from var(--ink,#1b2333) l c h / 0.14);
--pbb2-shd:var(--shadow,oklch(0.22 0.03 260));
--pbb2-marker:var(--marker,#fae37c);
--pbb2-bg:var(--button-bg,var(--cta,#d6342b));
--pbb2-bg2:var(--button-bg-2,var(--cta-2,#b52a22));
--pbb2-pad:clamp(18px,2.4vw,24px);
--pbb2-ease:cubic-bezier(.2,.7,.2,1);
position:relative;
background:var(--surface,#fff);
color:var(--ink,#1b2333);
font-family:var(--font-body,system-ui,sans-serif);
padding:clamp(56px,8vw,112px) var(--pbb2-gutter) clamp(64px,8.5vw,120px);
overflow-x:clip;
}
.cf-pbb2 *,.cf-pbb2 *::before,.cf-pbb2 *::after{box-sizing:border-box}
.cf-pbb2 :where(p,h2,h3,figure,ul,fieldset){margin:0}
.cf-pbb2 .sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.cf-pbb2 .inner{max-width:1120px;margin-inline:auto}
.cf-pbb2 .ico{display:inline-block;width:1em;height:1em;vertical-align:-0.15em;margin-inline-end:.4em}
.cf-pbb2 .mast{padding-top:0}
.cf-pbb2 .mast-name{font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:-0.035em;font-size:clamp(2.5rem,5.4vw,4.875rem);line-height:1;text-align:center;text-wrap:balance;margin-bottom:16px}
.cf-pbb2 .dateline{list-style:none;margin:0;padding:12px 0;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px 32px;border-block:1px solid var(--pbb2-hair);font-size:.875rem;line-height:1.2;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);text-align:center}
.cf-pbb2 .dateline li{position:relative}
.cf-pbb2 .dateline li+li::before{content:'';position:absolute;left:-18px;top:50%;width:5px;height:5px;margin-top:-2.5px;border-radius:50%;background:currentColor}
@media (max-width:639px){.cf-pbb2 .dateline{flex-direction:column;gap:8px}.cf-pbb2 .dateline li+li::before{display:none}}
.cf-pbb2 .front{display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:'lede' 'product' 'buy' 'story';gap:32px;align-items:start;margin-top:clamp(28px,4vw,48px)}
.cf-pbb2 .lede{grid-area:lede;min-width:0}
.cf-pbb2 .product{grid-area:product;min-width:0}
.cf-pbb2 .story{grid-area:story;min-width:0}
.cf-pbb2 .buy{grid-area:buy;min-width:0}
@media (min-width:720px){.cf-pbb2 .front{grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);grid-template-rows:auto auto 1fr;grid-template-areas:'lede lede' 'product buy' 'story buy';column-gap:clamp(32px,5vw,72px);row-gap:36px}}
@media (min-width:1040px){.cf-pbb2 .front{grid-template-columns:minmax(0,1fr) minmax(0,.9fr) minmax(0,1.2fr);grid-template-rows:auto 1fr;grid-template-areas:'lede lede buy' 'product story buy';column-gap:clamp(28px,3.2vw,48px);row-gap:40px}}
.cf-pbb2 .headline{font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,-0.025em);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance;color:var(--ink)}
.cf-pbb2 .lead{margin-top:16px;max-width:64ch;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .product{display:flex;flex-direction:column;align-items:center}
.cf-pbb2 .product img{display:block;width:100%;height:auto;max-height:clamp(280px,34vw,440px);object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--pbb2-shd) l c h / 0.3)) drop-shadow(0 16px 18px oklch(from var(--pbb2-shd) l c h / 0.22))}
.cf-pbb2 figcaption{margin-top:12px;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .product figcaption{margin-top:16px;text-align:center}
.cf-pbb2 .scene img{display:block;width:100%;height:auto;aspect-ratio:4/3;object-fit:cover;object-position:center;border-radius:12px}
.cf-pbb2 .story>p{margin-top:20px;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.55;text-wrap:pretty}
.cf-pbb2 .story>figure+p{margin-top:24px}
.cf-pbb2 .buy-h{margin-bottom:20px;font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:-0.01em;font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;text-wrap:balance}
.cf-pbb2 .choices{border:0;padding:0;min-width:0;display:grid;gap:16px}
.cf-pbb2 .tile{position:relative;background:var(--card);border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--shadow-sm);transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease,background-color .16s ease}
.cf-pbb2 .tile:not([data-selected]):not([data-disabled]):hover{border-color:oklch(from var(--ink) l c h / 0.32);box-shadow:var(--shadow-md);transform:translateY(-1px)}
.cf-pbb2 .tile[data-selected]{background:color-mix(in oklch,var(--accent) 7%,var(--card));border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent),var(--shadow-lg)}
.cf-pbb2 .tile[data-disabled]{background:color-mix(in oklch,var(--ink) 4%,var(--card));border-color:var(--card-border,oklch(from var(--ink) l c h / 0.12));box-shadow:none}
.cf-pbb2 .tile:has(.radio:focus-visible){outline:3px solid oklch(from var(--field-focus,var(--accent)) l c h / 0.6);outline-offset:3px}
.cf-pbb2 .tile-hit{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:'dot head price' '. reason reason';column-gap:16px;row-gap:12px;align-items:start;padding:var(--pbb2-pad);cursor:pointer}
.cf-pbb2 .tile[data-disabled] .tile-hit{cursor:not-allowed}
.cf-pbb2 .radio{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none}
.cf-pbb2 .dot{grid-area:dot;display:grid;place-items:center;width:26px;height:26px;margin-top:1px;border-radius:50%;border:2px solid oklch(from var(--ink) l c h / 0.32);background:var(--card);color:var(--accent-fill-ink,var(--card));transition:background-color .16s ease,border-color .16s ease}
.cf-pbb2 .dot svg{opacity:0;transition:opacity .16s ease}
.cf-pbb2 .tile[data-selected] .dot{background:var(--accent-fill,var(--accent));border-color:var(--accent-fill,var(--accent))}
.cf-pbb2 .tile[data-selected] .dot svg{opacity:1}
.cf-pbb2 .tile[data-disabled] .dot{background:color-mix(in oklch,var(--ink) 16%,var(--card));border-color:transparent;color:var(--ink)}
.cf-pbb2 .tile-head{grid-area:head;display:flex;flex-direction:column;gap:4px;min-width:0}
.cf-pbb2 .tile-title-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.cf-pbb2 .tile-title{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.2;letter-spacing:-0.01em}
.cf-pbb2 .tile-note{font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .flag{display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-size:.875rem;line-height:1.2;font-weight:800;white-space:nowrap}
.cf-pbb2 .tile-price{grid-area:price;text-align:right}
.cf-pbb2 .tile-num{display:block;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.1;letter-spacing:-0.02em;font-variant-numeric:tabular-nums}
.cf-pbb2 .tile-per{display:block;margin-top:4px;font-size:.9375rem;line-height:1.3;font-weight:500;color:var(--muted);white-space:nowrap}
.cf-pbb2 .tile-reason{grid-area:reason;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.45;text-wrap:pretty}
.cf-pbb2 .tile-reason mark{background-color:transparent;background-image:linear-gradient(transparent 6%,var(--pbb2-marker) 6%,var(--pbb2-marker) 94%,transparent 94%);color:oklch(from var(--pbb2-marker) calc(0.2 + clamp(0, (0.62 - l) * 100, 0.77)) 0.04 h);font-weight:700;padding:0 .22em;margin:0 -.04em;border-radius:.3em .55em .35em .5em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-pbb2 .tile-more{display:grid;gap:8px;padding:0 var(--pbb2-pad) var(--pbb2-pad) calc(var(--pbb2-pad) + 42px);animation:pbb2-rise .45s var(--pbb2-ease) both}
.cf-pbb2 .field-label{font-size:1rem;line-height:1.3;font-weight:700;color:var(--label-ink,var(--ink))}
.cf-pbb2 .select-wrap{position:relative}
.cf-pbb2 .select-wrap select{appearance:none;-webkit-appearance:none;width:100%;height:56px;padding:0 48px 0 16px;font-family:var(--font-body);font-size:17px;font-weight:600;color:var(--field-ink);background:var(--field);border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));cursor:pointer;transition:border-color .16s ease,box-shadow .16s ease}
.cf-pbb2 .select-wrap select:invalid{color:color-mix(in oklch,var(--field-ink) 65%,var(--field))}
.cf-pbb2 .select-wrap select option{color:var(--field-ink);background:var(--field)}
.cf-pbb2 .select-wrap select:hover:not(:disabled){border-color:color-mix(in oklch,var(--ink) 40%,transparent)}
.cf-pbb2 .select-wrap select:focus-visible{outline:none;border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--accent)) l c h / 0.35)}
.cf-pbb2 .select-wrap select[aria-invalid='true']{border-color:var(--danger);box-shadow:0 0 0 3px oklch(from var(--danger) l c h / 0.22)}
.cf-pbb2 .select-wrap select:disabled{cursor:not-allowed;background:color-mix(in oklch,var(--field-ink) 6%,var(--field))}
.cf-pbb2 .select-wrap svg{position:absolute;right:16px;top:50%;margin-top:-10px;pointer-events:none;color:var(--field-ink)}
.cf-pbb2 .field-error{font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--danger);text-wrap:pretty}
.cf-pbb2 .tile-terms{margin-top:4px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--ink);text-wrap:pretty}
.cf-pbb2 .tile-terms .ico{color:var(--success)}
.cf-pbb2 .qty{margin-top:24px;padding-bottom:20px;border-bottom:1px solid var(--pbb2-hair);display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:16px}
.cf-pbb2 .qty-label{min-width:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.3;font-weight:700;text-wrap:balance}
.cf-pbb2 .stepper{flex:none}
.cf-pbb2 .stepper{display:flex;align-items:center;gap:8px}
.cf-pbb2 .step{display:inline-grid;place-items:center;width:48px;height:48px;padding:0;cursor:pointer;border-radius:var(--button-radius,var(--radius,12px));background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));border:1px solid var(--button-2-border,transparent);box-shadow:var(--button-2-shadow,var(--shadow-sm));transition:transform .16s ease,box-shadow .16s ease,background-color .16s ease}
.cf-pbb2 .step:hover:not(:disabled){background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - 0.04) c h)}
.cf-pbb2 .step:active:not(:disabled){transform:translateY(1px);box-shadow:none}
.cf-pbb2 .step:disabled{cursor:not-allowed;box-shadow:none;color:color-mix(in oklch,var(--button-2-ink,var(--secondary-ink)) 40%,var(--button-2-bg,var(--secondary)))}
.cf-pbb2 .qty-val{display:grid;place-items:center;min-width:56px;height:48px;padding:0 12px;border-radius:var(--field-radius,var(--radius,12px));background:var(--field);color:var(--field-ink);border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.0625rem,1.25vw,1.125rem);font-variant-numeric:tabular-nums}
.cf-pbb2 .tag{position:relative;margin-top:24px;text-align:center;background:var(--card);border:1px solid var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-md));padding:clamp(20px,3vw,28px) clamp(20px,3vw,32px)}
.cf-pbb2 .tag-was-line{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 12px;margin-inline:auto;margin-bottom:12px}
.cf-pbb2 .tag-price{display:flex;justify-content:center;margin-inline:auto}
.cf-pbb2 .tag-was{position:relative;text-decoration:none;white-space:nowrap;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1;color:var(--muted);font-variant-numeric:tabular-nums}
.cf-pbb2 .tag-was::after{content:'';position:absolute;left:-6%;right:-6%;top:50%;height:2px;margin-top:-1px;border-radius:2px;background:var(--danger);transform:rotate(-4deg)}
.cf-pbb2 .tag-save{display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;background:var(--success-soft);color:var(--success);font-size:.875rem;line-height:1.2;font-weight:800;white-space:nowrap}
.cf-pbb2 .tag-now{display:inline-block;font-family:var(--font-display);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;color:var(--ink);animation:pbb2-pop .3s var(--pbb2-ease) both}
.cf-pbb2 .tag-per{margin-top:12px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .instruction{margin-top:28px;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.45;font-weight:700;text-wrap:pretty}
.cf-pbb2 .note{margin-top:28px;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .btn{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;border:0;cursor:pointer;font-family:var(--button-font,var(--font-display));font-weight:var(--button-weight,800);text-transform:var(--button-case,none);color:var(--button-ink,var(--cta-ink,#fff));text-shadow:var(--button-text-shadow,none);border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from var(--pbb2-bg) calc(l + 0.04) c h),oklch(from var(--pbb2-bg2) calc(l - 0.02) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--pbb2-bg) calc(l + 0.14) c h / 0.7),inset 0 -3px 0 oklch(from var(--pbb2-bg) calc(l - 0.16) c h),0 1px 2px oklch(from var(--pbb2-shd) l c h / 0.3),0 8px 16px -6px oklch(from var(--pbb2-shd) l c h / 0.45));transition:transform .16s ease,box-shadow .16s ease,background .16s ease;-webkit-tap-highlight-color:transparent}
.cf-pbb2 .btn:hover:not(:disabled),.cf-pbb2 .btn[data-force='hover']:not(:disabled){background:linear-gradient(oklch(from var(--pbb2-bg) calc(l - 0.01) c h),oklch(from var(--pbb2-bg2) calc(l - 0.07) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--pbb2-bg) calc(l + 0.12) c h / 0.6),inset 0 -3px 0 oklch(from var(--pbb2-bg) calc(l - 0.18) c h),0 1px 2px oklch(from var(--pbb2-shd) l c h / 0.32),0 10px 18px -6px oklch(from var(--pbb2-shd) l c h / 0.5))}
.cf-pbb2 .btn:active:not(:disabled),.cf-pbb2 .btn[data-force='active']:not(:disabled){transform:translateY(1px);background:linear-gradient(oklch(from var(--pbb2-bg) calc(l - 0.04) c h),oklch(from var(--pbb2-bg2) calc(l - 0.09) c h));box-shadow:inset 0 2px 4px oklch(from var(--pbb2-bg) calc(l - 0.22) c h / 0.45),inset 0 -2px 0 oklch(from var(--pbb2-bg) calc(l - 0.16) c h),0 1px 1px oklch(from var(--pbb2-shd) l c h / 0.3)}
.cf-pbb2 .btn:focus-visible,.cf-pbb2 .step:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
.cf-pbb2 .btn:disabled{cursor:not-allowed;background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));text-shadow:none;box-shadow:none}
.cf-pbb2 .btn-main{width:100%;min-height:72px;margin-top:16px;padding:12px 28px;text-align:center}
.cf-pbb2 .btn-label{font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.15}
.cf-pbb2 .btn-sub{margin-top:4px;font-family:var(--font-body);font-weight:600;font-size:.9375rem;line-height:1.3;text-transform:none;text-wrap:balance}
.cf-pbb2 .nb{white-space:nowrap}
.cf-pbb2 .assure{margin-top:16px;text-align:center;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--muted);text-wrap:pretty}
.cf-pbb2 .assure .ico{color:var(--success)}
.cf-pbb2 .bar{display:none}
.cf-pbb2 .bar-info{min-width:0;display:flex;flex-direction:column;gap:2px}
.cf-pbb2 .bar-choice{font-size:.875rem;line-height:1.25;font-weight:800;color:var(--muted);text-wrap:balance;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.cf-pbb2 .bar-price{font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.1;letter-spacing:-0.02em;font-variant-numeric:tabular-nums}
.cf-pbb2 .btn-bar{flex:none;min-height:52px;padding:0 22px;white-space:nowrap;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.15}
@media (max-width:719px){
.cf-pbb2 .bar{position:sticky;bottom:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:12px;margin:32px calc(-1 * var(--pbb2-gutter)) 0;padding:12px var(--pbb2-gutter) calc(12px + env(safe-area-inset-bottom,0px));background:var(--card);color:var(--ink);box-shadow:0 -1px 2px oklch(from var(--pbb2-shd) l c h / 0.14),0 -8px 16px -8px oklch(from var(--pbb2-shd) l c h / 0.3);transition:transform .25s var(--pbb2-ease),visibility .25s}
.cf-pbb2 .bar[data-hidden]{transform:translateY(110%);visibility:hidden}
}
.cf-pbb2 .lede,.cf-pbb2 .product,.cf-pbb2 .story,.cf-pbb2 .buy{animation:pbb2-rise .45s var(--pbb2-ease) both}
.cf-pbb2 .buy{animation-delay:.07s}
.cf-pbb2 .product{animation-delay:.14s}
.cf-pbb2 .story{animation-delay:.21s}
@keyframes pbb2-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes pbb2-pop{from{opacity:.82;transform:scale(.92)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){
.cf-pbb2 *,.cf-pbb2 *::before,.cf-pbb2 *::after{animation:none !important;transition:none !important}
.cf-pbb2 .tile:not([data-selected]):not([data-disabled]):hover{transform:none}
}
`
pieces/offer/product-buy-box-2/specimen.tsx 62 lines
import __studioImage84f43ccc from "../assets/14e5da7613ce1531.webp";
import __studioImage7167f44a from "../assets/e6e45904869c926d.webp";
// Specimen: Ridgeline whole-bean coffee, a fictional subscribe-and-save product page front.
import * as React from 'react'
import { ProductBuyBox2, type ProductBuyBox2State } from '../product-buy-box-2'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function ProductBuyBox2Specimen({ state = 'default' }: { state?: ProductBuyBox2State }) {
return (
<ProductBuyBox2
state={state}
masthead='Ridgeline'
dateline={['Whole bean · 12 oz bag', 'Roasted to order', 'Ships once or on your schedule']}
headline='Fresh beans at your door before the last scoop'
lead='Buy one bag or set a delivery schedule. Every bag is roasted after you order and shipped whole bean.'
productImage={slot(
'product',
__studioImage84f43ccc
)}
productImageAlt='Ridgeline whole-bean coffee, 12 oz bag'
productCaption='Ridgeline whole bean, 12 oz. A medium roast with notes of cocoa and toasted almond.'
sceneImage={slot(
'scene',
__studioImage7167f44a
)}
sceneImageAlt='Hot water poured over fresh grounds in a pour-over dripper'
sceneCaption='Grind right before you brew. Whole beans hold their flavour far longer than pre-ground.'
story={[
'Most supermarket coffee was roasted weeks before you picked it up. Ridgeline is roasted after your order comes in, sealed in a valve bag and sent out whole bean.',
'Subscribe and it arrives on the schedule you pick. Running low early? Move your next bag up, skip one, or cancel from your account.',
]}
oneTime={{ price: '$22.00', note: 'Ships once. No commitment.' }}
subscription={{
price: '$18.70',
badge: 'Save 15%',
reasonWhy: 'We roast subscriber orders in planned batches, so nothing goes stale on a shelf. That saving comes off your bag.',
reasonHighlight: 'nothing goes stale on a shelf',
cadences: [
{ value: '1w', label: 'Every week' },
{ value: '2w', label: 'Every 2 weeks' },
{ value: '3w', label: 'Every 3 weeks' },
{ value: '4w', label: 'Every 4 weeks' },
],
defaultCadence: '2w',
terms: 'Skip, move or cancel any delivery from your account.',
}}
quantity={{ min: 1, max: 6, initial: 1 }}
assurance={defaults.sample.guarantee}
copy={{
choiceHeading: 'Buy it once, or never run out of beans',
perUnit: 'per bag',
perUnitSubscribe: 'per bag, every delivery',
quantityLabel: 'How many bags?',
instruction: 'Click the button below to add Ridgeline to your cart.',
disabledNote: 'Ridgeline is sold out this week. New roasts open soon.',
}}
/>
)
}
| Name | Type | Details |
|---|---|---|
masthead RequiredProductBuyBox2 |
string |
|
dateline OptionalProductBuyBox2 |
string[] |
Default []
|
headline RequiredProductBuyBox2 |
React.ReactNode |
|
lead OptionalProductBuyBox2 |
string |
|
productImage OptionalProductBuyBox2 |
string |
|
productImageAlt OptionalProductBuyBox2 |
string |
Default ''
|
productCaption OptionalProductBuyBox2 |
string |
|
sceneImage OptionalProductBuyBox2 |
string |
|
sceneImageAlt OptionalProductBuyBox2 |
string |
Default ''
|
sceneCaption OptionalProductBuyBox2 |
string |
|
story OptionalProductBuyBox2 |
string[] |
Default []
|
oneTime RequiredProductBuyBox2 |
{ price: string; note?: string } |
|
subscription OptionalProductBuyBox2 |
ProductBuyBox2Subscription |
|
defaultPlan OptionalProductBuyBox2 |
ProductBuyBox2Plan |
|
quantity OptionalProductBuyBox2 |
{ min?: number; max?: number; initial?: number } |
|
assurance OptionalProductBuyBox2 |
string |
|
disabled OptionalProductBuyBox2 |
boolean |
Default false
|
state OptionalProductBuyBox2 |
ProductBuyBox2State |
Default 'default'
|
copy OptionalProductBuyBox2 |
Partial<ProductBuyBox2Copy> |
|
onSubmit OptionalProductBuyBox2 |
(order: ProductBuyBox2Order) => void |
|
onAction OptionalProductBuyBox2 |
() => void |
|
href OptionalProductBuyBox2 |
string |
|
className OptionalProductBuyBox2 |
string |
Default ''
|
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-border--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--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.
product- The main product shot or cover (ebook, kit, bottle).
scene- A wide atmosphere photo behind or beside the copy.
-
14e5da7613ce1531.webp
image/webp · 66.5 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
e6e45904869c926d.webp
image/webp · 66 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB