Quantity Breaks 2
Volume quantity breaks for team orders: a slider synced to a number input, the supplied price breaks notched on the track,
Use it in a prompt
Use offer/quantity-breaks-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/quantity-breaks-2.tsx. - Import it and pass your copy and images (Props tab):
import { QuantityBreaks2 } from "@/components/funneldna/offer/quantity-breaks-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/quantity-breaks-2/component.tsx 753 lines
// layout: fact-scoreboard
// Volume quantity breaks for team orders: a slider synced to a number input, the supplied price breaks notched on the track,
// and a live scoreboard of price each, order total and saving, so the buyer watches the unit price fall as they cross a break.
import * as React from 'react'
import { AlertCircle, Loader2, Minus, Plus, ShieldCheck, Tag } from 'lucide-react'
import { FX_HOST, Pattern } from '../fx/fx'
export type QuantityBreaks2Break = {
/** Smallest quantity that gets this price. */
min: number
/** Price per unit from this quantity up, in `currency`. */
price: number
/** Tier name that flashes when the order crosses into it, e.g. Team pack. */
label?: string
}
export type QuantityBreaks2Order = {
quantity: number
unitPrice: number
total: number
/** Tier reached, when that break has a label. */
tier?: string
/** Saving against the single-unit price; 0 when none follows from the breaks. */
saving: number
}
export type QuantityBreaks2State = 'default' | 'hover' | 'active' | 'disabled' | 'error'
export type QuantityBreaks2Copy = typeof DEFAULT_COPY
export type QuantityBreaks2Props = {
heading?: string
/** Phrase inside the heading that gets the marker stroke. */
highlight?: string
lead?: string
productName?: string
/** One short line under the product name. */
productNote?: string
/** Transparent product cut-out (slot: product). */
productImage?: string
productImageAlt?: string
/** Singular unit word, e.g. notebook. */
unit?: string
unitPlural?: string
/** Supplied price breaks; the lowest min sets the smallest order. */
breaks?: QuantityBreaks2Break[]
/** Single-unit price for the saving; defaults to the break that starts at 1. */
singlePrice?: number
/** Smallest order allowed; never below the first break. */
min?: number
/** Largest order allowed (an order limit, not scarcity). */
max?: number
defaultQuantity?: number
/** ISO currency code. */
currency?: string
locale?: string
/** Red mid-copy subhead for the reason why; the block hides when both are empty. */
reasonTitle?: string
reasonText?: string
/** One line under the button; hidden when empty. */
reassurance?: string
/** Generated and accessible text; templates keep their {placeholders}. */
copy?: Partial<QuantityBreaks2Copy>
state?: QuantityBreaks2State
/** Receives the validated order. The builder wires what happens next. */
onSubmit?: (order: QuantityBreaks2Order) => void | Promise<void>
className?: string
}
export function QuantityBreaks2({
heading = 'Kit out the whole team and the price per notebook drops',
highlight = 'the price per notebook drops',
lead = 'Slide to your team size. Every notch you pass lowers the price of every notebook in the order.',
productName = 'Brightpath custom team notebooks',
productNote = 'Your logo on the cover · A5 · 160 pages',
productImage,
productImageAlt = '',
unit = 'notebook',
unitPlural,
breaks = DEFAULT_BREAKS,
singlePrice,
min,
max = 250,
defaultQuantity,
currency = 'USD',
locale = 'en-US',
reasonTitle = 'Why bigger orders cost less per notebook',
reasonText = 'Setting up your cover art and the press takes the same time for 10 notebooks or 100. Order more at once and that setup is shared across every notebook, so each one costs you less.',
reassurance = '',
copy,
state = 'default',
onSubmit,
className,
}: QuantityBreaks2Props) {
const c = { ...DEFAULT_COPY, ...copy }
const plural = unitPlural ?? unit + 's'
const uid = 'qb2' + React.useId().split(':').join('')
const tiers = React.useMemo(() => cleanBreaks(breaks), [breaks])
const first = tiers[0]
const lo = first ? Math.max(Math.floor(min ?? first.min), first.min) : 1
const hi = Math.max(Math.floor(max), lo + 1)
const stops = React.useMemo(() => {
const inner = tiers.map((t) => t.min).filter((m) => m > lo && m < hi)
return [lo, ...inner, hi]
}, [tiers, lo, hi])
const seg = stops.length - 1
const start = clamp(Math.round(defaultQuantity ?? lo), lo, hi)
const [qty, setQty] = React.useState(start)
const [raw, setRaw] = React.useState(String(start))
const [pending, setPending] = React.useState(false)
const [failed, setFailed] = React.useState(false)
const [flash, setFlash] = React.useState(0)
const [announce, setAnnounce] = React.useState('')
const mounted = React.useRef(true)
const inputRef = React.useRef<HTMLInputElement>(null)
const quantity = clamp(qty, lo, hi)
const tierIndex = tierIndexAt(tiers, quantity)
const lastTier = React.useRef(tierIndex)
React.useEffect(() => {
mounted.current = true
return () => {
mounted.current = false
}
}, [])
React.useEffect(() => {
if (state === 'error') setRaw(String(hi + 50))
}, [state, hi])
React.useEffect(() => {
if (lastTier.current === tierIndex) return
lastTier.current = tierIndex
setFlash((f) => f + 1)
const t = tiers[tierIndex]
if (t) {
setAnnounce(
fill(t.label ? c.announce : c.announcePlain, {
tier: t.label ?? '',
price: money(t.price, currency, locale),
unit,
}),
)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tierIndex])
const tier = tiers[tierIndex]
if (!tier) return null
const fmt = (n: number) => money(n, currency, locale)
const unitsFor = (n: number) => (n === 1 ? unit : plural)
const unitPrice = tier.price
const single = singlePrice ?? (first && first.min === 1 ? first.price : undefined)
const total = round2(unitPrice * quantity)
const savingEach = single !== undefined ? round2(single - unitPrice) : 0
const saving = savingEach > 0 ? round2(savingEach * quantity) : 0
const percent = single && saving > 0 ? Math.round((savingEach / single) * 100) : 0
const next = tiers.find((t) => t.min > quantity && t.min <= hi)
const parsed = Number(raw)
const invalid = raw.trim() === '' || !Number.isInteger(parsed) || parsed < lo || parsed > hi
const disabled = state === 'disabled'
const blocked = disabled || invalid
const force = state === 'hover' || state === 'active' ? state : undefined
const pos = toPos(stops, quantity)
const headingId = uid + '-h'
const inputId = uid + '-qty'
const errId = uid + '-err'
const unitNote = single !== undefined && unitPrice < single ? fill(c.unitNote, { single: fmt(single) }) : ''
const third =
saving > 0
? { label: c.savingLabel, value: fmt(saving), note: percent >= 1 ? fill(c.savingNote, { percent }) : '', word: false }
: next
? { label: c.nextLabel, value: String(next.min), note: fill(c.nextNote, { price: fmt(next.price), unit }), word: false }
: { label: c.tierLabel, value: tier.label ?? fmt(unitPrice), note: '', word: !!tier.label }
const nudge = next
? rich(c.nudge, { more: next.min - quantity, unit, price: fmt(next.price) }, ['more', 'price'])
: rich(tier.label ? c.nudgeTop : c.nudgeTopPlain, { tier: tier.label ?? '', unit }, ['tier'])
const anchor =
single !== undefined && saving > 0
? rich(
c.anchor,
{ total: fmt(total), quantity, units: unitsFor(quantity), singleTotal: fmt(round2(single * quantity)) },
['total'],
)
: rich(c.anchorPlain, { total: fmt(total), quantity, units: unitsFor(quantity) }, ['total'])
const valueText = fill(c.valueText, { quantity, units: unitsFor(quantity), price: fmt(unitPrice) })
function commit(n: number) {
const v = clamp(Math.round(n), lo, hi)
setQty(v)
setRaw(String(v))
setFailed(false)
}
function onRangeKey(e: React.KeyboardEvent<HTMLInputElement>) {
let to: number | null = null
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') to = quantity + 1
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') to = quantity - 1
else if (e.key === 'PageUp') to = quantity + 10
else if (e.key === 'PageDown') to = quantity - 10
else if (e.key === 'Home') to = lo
else if (e.key === 'End') to = hi
if (to !== null) {
e.preventDefault()
commit(to)
}
}
function onInput(e: React.ChangeEvent<HTMLInputElement>) {
const v = e.target.value
setRaw(v)
setFailed(false)
const n = Number(v)
if (v.trim() !== '' && Number.isInteger(n) && n >= lo && n <= hi) setQty(n)
}
function onBlur() {
if (!invalid) setRaw(String(parsed))
}
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault()
if (invalid) {
inputRef.current?.focus()
return
}
if (disabled || pending || !onSubmit) return
setPending(true)
setFailed(false)
try {
await onSubmit({ quantity, unitPrice, total, tier: tier.label, saving })
} catch {
if (mounted.current) setFailed(true)
} finally {
if (mounted.current) setPending(false)
}
}
return (
<section
className={'cf-quantity-breaks-2' + (className ? ' ' + className : '')}
style={{ ...FX_HOST, overflow: 'clip' }}
aria-labelledby={headingId}
data-force={force}
data-disabled={disabled || undefined}
>
<style>{CSS}</style>
<Pattern name='grid' fade='edges' />
<div className='qb2-wrap'>
<header className='qb2-head qb2-rise'>
<h2 id={headingId} className='qb2-h2'>
{withMark(heading, highlight)}
</h2>
{lead ? <p className='qb2-lead'>{lead}</p> : null}
</header>
<form className='qb2-board' onSubmit={handleSubmit} noValidate aria-busy={pending || undefined}>
<dl className='qb2-score qb2-rise' style={{ '--d': '.07s' } as React.CSSProperties} aria-label={c.scoreLabel}>
<div className='qb2-tile qb2-tile--unit'>
<dt className='qb2-tl'>{fill(c.unitLabel, { unit })}</dt>
{tier.label ? (
<dd key={'chip-' + flash} className='qb2-chip' data-flash={flash > 0 || undefined}>
{tier.label}
</dd>
) : null}
<dd className='qb2-tv'>{fmt(unitPrice)}</dd>
{unitNote ? <dd className='qb2-tn'>{unitNote}</dd> : null}
</div>
<div className='qb2-tile'>
<dt className='qb2-tl'>{c.totalLabel}</dt>
<dd className='qb2-tv'>{fmt(total)}</dd>
<dd className='qb2-tn'>{fill(c.totalNote, { quantity, units: unitsFor(quantity) })}</dd>
</div>
<div className='qb2-tile'>
<dt className='qb2-tl'>{third.label}</dt>
<dd className={'qb2-tv' + (third.word ? ' qb2-tv--word' : '')}>{third.value}</dd>
{third.note ? <dd className='qb2-tn'>{third.note}</dd> : null}
</div>
</dl>
<div className='qb2-dial qb2-rise' style={{ '--d': '.14s' } as React.CSSProperties}>
<div className='qb2-prod'>
{productImage ? (
<img className='qb2-shot' src={productImage} alt={productImageAlt} width={512} height={512} loading='lazy' decoding='async' />
) : null}
<div>
<h3 className='qb2-h3'>{productName}</h3>
{productNote ? <p className='qb2-pnote'>{productNote}</p> : null}
</div>
</div>
<div className='qb2-qty'>
<label className='qb2-label' htmlFor={inputId}>
{fill(c.inputLabel, { units: plural })}
</label>
<div className='qb2-row'>
<button
type='button'
className='qb2-sb'
onClick={() => commit(quantity - 1)}
disabled={disabled || quantity <= lo}
aria-label={fill(c.minus, { unit })}
>
<Minus size={20} strokeWidth={2.5} aria-hidden />
</button>
<input
ref={inputRef}
id={inputId}
className='qb2-field'
type='number'
inputMode='numeric'
min={lo}
max={hi}
step={1}
value={raw}
placeholder={String(stops[1] ?? lo)}
onChange={onInput}
onBlur={onBlur}
disabled={disabled}
aria-invalid={invalid || undefined}
aria-describedby={invalid ? errId : undefined}
/>
<button
type='button'
className='qb2-sb'
onClick={() => commit(quantity + 1)}
disabled={disabled || quantity >= hi}
aria-label={fill(c.plus, { unit })}
>
<Plus size={20} strokeWidth={2.5} aria-hidden />
</button>
<span className='qb2-units' aria-hidden>
{unitsFor(quantity)}
</span>
</div>
<p id={errId} className='qb2-err' aria-live='polite'>
{invalid ? (
<>
<AlertCircle className='qb2-ic' size={18} strokeWidth={2.5} aria-hidden />
{fill(c.error, { min: lo, max: hi })}
</>
) : null}
</p>
</div>
<div className='qb2-slide'>
<div className='qb2-ticks' aria-hidden>
{stops.slice(0, -1).map((s, i) => (
<span
key={s}
className='qb2-tick'
data-on={s <= quantity || undefined}
style={{ left: (i / seg) * 100 + '%' }}
/>
))}
</div>
<input
className='qb2-range'
type='range'
min={0}
max={1000}
step={1}
value={Math.round(pos * 1000)}
onChange={(e) => commit(toQty(stops, Number(e.target.value) / 1000))}
onKeyDown={onRangeKey}
disabled={disabled}
aria-label={c.sliderLabel}
aria-valuetext={valueText}
style={{ '--pos': `calc(var(--qb2-t) + ${pos} * (100% - 2 * var(--qb2-t)))` } as React.CSSProperties}
/>
</div>
<div className='qb2-ladder' style={{ gridTemplateColumns: `repeat(${seg}, minmax(0, 1fr))` }}>
{stops.slice(0, -1).map((s) => {
const ti = tierIndexAt(tiers, s)
const t = tiers[ti]
const current = ti === tierIndex
return (
<button
key={current ? s + '-' + flash : String(s)}
type='button'
className='qb2-rung'
data-on={s <= quantity || undefined}
data-current={current || undefined}
data-flash={(current && flash > 0) || undefined}
onClick={() => commit(s)}
disabled={disabled}
aria-label={fill(c.stepAria, { quantity: s, units: unitsFor(s), price: fmt(t.price) })}
>
<b>{fill(c.stepMin, { min: s })}</b>
<span>{fmt(t.price)}</span>
</button>
)
})}
</div>
<p className='qb2-nudge'>
<Tag className='qb2-ic' size={18} strokeWidth={2.5} aria-hidden />
{nudge}
</p>
{reasonTitle || reasonText ? (
<div className='qb2-reason'>
{reasonTitle ? <h3 className='qb2-red'>{reasonTitle}</h3> : null}
{reasonText ? <p className='qb2-why'>{reasonText}</p> : null}
</div>
) : null}
</div>
<div className='qb2-act qb2-rise' style={{ '--d': '.21s' } as React.CSSProperties}>
<p className='qb2-anchor'>{anchor}</p>
<button
type='submit'
className='qb2-btn'
disabled={blocked}
aria-describedby={invalid ? errId : undefined}
>
{pending ? (
<span className='qb2-btn-main'>
<Loader2 className='qb2-spin' size={20} strokeWidth={2.5} aria-hidden />
{c.loading}
</span>
) : (
<>
<span className='qb2-btn-main'>{fill(c.cta, { quantity, units: unitsFor(quantity) })}</span>
<span className='qb2-btn-sub'>{fill(c.ctaSub, { price: fmt(unitPrice), unit })}</span>
</>
)}
</button>
{reassurance ? (
<p className='qb2-assure'>
<ShieldCheck className='qb2-ic qb2-ic--ok' size={18} strokeWidth={2.5} aria-hidden />
{reassurance}
</p>
) : null}
{failed ? (
<p className='qb2-aerr' role='alert'>
<AlertCircle className='qb2-ic' size={18} strokeWidth={2.5} aria-hidden />
{c.actionError}
</p>
) : null}
</div>
</form>
<p className='qb2-sr' aria-live='polite'>
{announce}
</p>
</div>
</section>
)
}
export default QuantityBreaks2
const DEFAULT_BREAKS: QuantityBreaks2Break[] = [
{ min: 1, price: 24, label: 'Single' },
{ min: 10, price: 21, label: 'Team pack' },
{ min: 25, price: 18, label: 'Squad' },
{ min: 50, price: 15, label: 'Department' },
{ min: 100, price: 12, label: 'Company-wide' },
]
const DEFAULT_COPY = {
/** {units} */
inputLabel: 'How many {units} does your team need?',
sliderLabel: 'Order quantity',
/** {quantity} {units} {price} */
valueText: '{quantity} {units}, {price} each',
/** {unit} */
minus: 'Remove one {unit}',
/** {unit} */
plus: 'Add one {unit}',
scoreLabel: 'Your order at a glance',
/** {unit} */
unitLabel: 'Each {unit}',
/** {single} */
unitNote: 'Single price {single}',
totalLabel: 'Order total',
/** {quantity} {units} */
totalNote: '{quantity} {units}',
savingLabel: 'You save',
/** {percent} */
savingNote: '{percent}% off the single price',
nextLabel: 'Next price break',
/** {price} {unit} */
nextNote: 'Drops to {price} per {unit}',
tierLabel: 'Your price tier',
/** {min} */
stepMin: '{min}+',
/** {quantity} {units} {price} */
stepAria: 'Set {quantity} {units} at {price} each',
/** {more} {unit} {price} */
nudge: 'Add {more} more and every {unit} drops to {price}.',
/** {tier} */
nudgeTop: 'You’re on the {tier} price, the last break on the slider.',
nudgeTopPlain: 'You’re on the last price break on the slider.',
/** {total} {quantity} {units} {singleTotal} */
anchor: '{total} for {quantity} {units}, vs. {singleTotal} at the single price.',
/** {total} {quantity} {units} */
anchorPlain: '{total} for {quantity} {units}.',
/** {quantity} {units} */
cta: 'Order {quantity} {units}',
/** {price} {unit} */
ctaSub: 'Lock in {price} per {unit}',
loading: 'Starting your order…',
/** {min} {max} */
error: 'Choose a whole number from {min} to {max}.',
actionError: 'We couldn’t start your order. Please try again.',
/** {tier} {price} {unit} */
announce: '{tier} price unlocked: {price} per {unit}.',
/** {price} {unit} */
announcePlain: 'Now {price} per {unit}.',
}
function cleanBreaks(list: QuantityBreaks2Break[] | undefined): QuantityBreaks2Break[] {
const ok = (list ?? [])
.filter((b) => b && Number.isFinite(b.min) && b.min >= 1 && Number.isFinite(b.price) && b.price >= 0)
.map((b) => ({ ...b, min: Math.floor(b.min) }))
.sort((a, b) => a.min - b.min)
return ok.filter((b, i) => i === 0 || b.min !== ok[i - 1].min)
}
function tierIndexAt(tiers: QuantityBreaks2Break[], q: number) {
let idx = 0
for (let i = 0; i < tiers.length; i++) if (tiers[i].min <= q) idx = i
return idx
}
/** Quantity to a 0–1 track position; each segment between breaks gets an equal share of the track. */
function toPos(stops: number[], q: number) {
const seg = stops.length - 1
for (let i = 0; i < seg; i++) {
const a = stops[i]
const b = stops[i + 1]
if (q <= b || i === seg - 1) return clamp((i + (q - a) / (b - a)) / seg, 0, 1)
}
return 0
}
function toQty(stops: number[], f: number) {
const seg = stops.length - 1
const x = clamp(f, 0, 1) * seg
const i = Math.min(seg - 1, Math.floor(x))
return Math.round(stops[i] + (x - i) * (stops[i + 1] - stops[i]))
}
function clamp(n: number, a: number, b: number) {
return Math.min(b, Math.max(a, n))
}
function round2(n: number) {
return Math.round(n * 100) / 100
}
function money(n: number, currency: string, locale: string) {
const d = Math.round(n * 100) % 100 !== 0 ? 2 : 0
try {
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
minimumFractionDigits: d,
maximumFractionDigits: d,
}).format(n)
} catch {
return n.toFixed(d)
}
}
function fill(tpl: string, vars: Record<string, string | number>) {
let out = tpl
for (const k of Object.keys(vars)) out = out.split('{' + k + '}').join(String(vars[k]))
return out
}
/** Fills a template, setting the named values in bold. */
function rich(tpl: string, vars: Record<string, string | number>, bold: string[]) {
const out: React.ReactNode[] = []
let rest = tpl
let key = 0
while (rest.length) {
const a = rest.indexOf('{')
const b = a < 0 ? -1 : rest.indexOf('}', a)
if (a < 0 || b < 0) {
out.push(rest)
break
}
if (a > 0) out.push(rest.slice(0, a))
const name = rest.slice(a + 1, b)
const v = vars[name]
if (v === undefined) out.push(rest.slice(a, b + 1))
else out.push(bold.indexOf(name) >= 0 ? <strong key={key++}>{v}</strong> : String(v))
rest = rest.slice(b + 1)
}
return out
}
function withMark(text: string, mark?: string): React.ReactNode {
if (!mark) return text
const at = text.indexOf(mark)
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='qb2-mark'>{mark}</span>
{text.slice(at + mark.length)}
</>
)
}
const R = '.cf-quantity-breaks-2'
const CSS = `
${R}{--qb2-shadow:var(--shadow, oklch(0.22 0.03 260));--qb2-marker:var(--marker, #fae37c);--qb2-red:color-mix(in oklab, var(--cta) 48%, var(--ink));--qb2-fill:var(--accent-fill, var(--accent));--qb2-focus:var(--field-focus, var(--accent));--qb2-t:14px;
box-sizing:border-box;background:var(--surface);color:var(--ink);font-family:var(--font-body);
padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) clamp(64px,8.5vw,120px)}
${R} *,${R} *::before,${R} *::after{box-sizing:border-box}
${R} .qb2-wrap{position:relative;z-index:1;max-width:1120px;margin:0 auto}
${R} .qb2-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
${R} .qb2-ic{display:inline-block;vertical-align:-0.15em;margin-inline-end:.4em;flex:0 0 auto}
${R} .qb2-head{max-width:46rem;margin:0 auto 48px;text-align:center}
${R} .qb2-h2{margin:0;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;text-wrap:balance;color:var(--ink)}
${R} .qb2-mark{background-image:linear-gradient(var(--qb2-marker),var(--qb2-marker));background-repeat:no-repeat;background-size:100% .5em;background-position:0 86%;padding:0 .08em;margin:0 -.04em;border-radius:.1em .3em .12em .25em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
${R} .qb2-lead{margin:16px auto 0;max-width:40rem;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .qb2-board{display:grid;gap:16px;grid-template-columns:minmax(0,1fr);grid-template-areas:'score' 'dial' 'act'}
@media (min-width:900px){${R} .qb2-board{gap:24px;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);grid-template-areas:'dial score' 'dial act';align-items:start}}
${R} .qb2-score{grid-area:score;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:0}
@media (min-width:900px){${R} .qb2-score{gap:16px}}
${R} .qb2-tile--unit{grid-column:1 / -1;display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;align-items:start}
${R} .qb2-tile--unit > .qb2-tv,${R} .qb2-tile--unit > .qb2-tn{grid-column:1 / -1}
${R} .qb2-tile{container-type:inline-size;min-width:0;margin:0;padding:16px 16px 20px;border-radius:var(--card-radius, var(--radius, 14px));background:var(--band);color:var(--band-ink);
box-shadow:inset 0 1px 0 oklch(from var(--band) calc(l + 0.1) c h), var(--shadow-md, 0 1px 2px oklch(from var(--qb2-shadow) l c h / .22), 0 4px 10px -2px oklch(from var(--qb2-shadow) l c h / .2))}
@media (min-width:640px){${R} .qb2-tile{padding:clamp(20px,3vw,32px)}}
${R} .qb2-tl{margin:0;font-size:.875rem;line-height:1.2;font-weight:800;letter-spacing:.06em;text-transform:uppercase;text-wrap:balance;color:color-mix(in oklch, var(--band-ink) 84%, var(--band))}
${R} .qb2-tv{margin:12px 0 0;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:-0.03em;line-height:1;font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--band-ink);font-size:min(clamp(1.75rem,7vw,2.5rem),24cqi)}
${R} .qb2-tile--unit .qb2-tv{font-size:min(clamp(2.5rem,11vw,4.875rem),30cqi)}
${R} .qb2-tv--word{white-space:normal;letter-spacing:-0.01em;line-height:1.15;font-size:min(clamp(1.0625rem,4vw,1.625rem),18cqi);text-wrap:balance}
@media (min-width:900px){${R} .qb2-tv{font-size:min(clamp(2rem,3.6vw,3.25rem),20cqi)}${R} .qb2-tile--unit .qb2-tv{font-size:min(clamp(2.5rem,5.4vw,4.875rem),30cqi)}${R} .qb2-tv--word{font-size:clamp(1.3125rem,1.8vw,1.625rem)}}
${R} .qb2-tn{margin:12px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;text-wrap:pretty;color:color-mix(in oklch, var(--band-ink) 84%, var(--band))}
${R} .qb2-dial{grid-area:dial;min-width:0;padding:clamp(20px,3vw,32px);background:var(--card);color:var(--ink);border:1px solid var(--card-border, oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius, var(--radius, 14px));box-shadow:var(--card-shadow, var(--shadow-md, 0 1px 2px oklch(from var(--qb2-shadow) l c h / .22), 0 4px 10px -2px oklch(from var(--qb2-shadow) l c h / .2)))}
${R} .qb2-prod{display:flex;align-items:flex-start;gap:16px}
${R} .qb2-shot{flex:0 0 auto;display:block;width:76px;height:76px;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--qb2-shadow) l c h / .3)) drop-shadow(0 10px 12px oklch(from var(--qb2-shadow) l c h / .2))}
@media (min-width:640px){${R} .qb2-shot{width:112px;height:112px}}
${R} .qb2-h3{margin:4px 0 0;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance;color:var(--ink)}
${R} .qb2-pnote{margin:8px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .qb2-qty{margin-top:24px}
${R} .qb2-label{display:block;margin-bottom:12px;font-size:1.0625rem;line-height:1.3;font-weight:700;color:var(--label-ink, var(--ink));text-wrap:pretty}
${R} .qb2-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
${R} .qb2-field{width:5.5rem;min-height:56px;padding:0 12px;text-align:center;border-radius:var(--field-radius, var(--radius, 12px));border:1px solid var(--field-border, color-mix(in oklch, var(--ink) 22%, transparent));background:var(--field);color:var(--field-ink);
font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1;font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield;transition:border-color .16s ease, box-shadow .16s ease}
${R} .qb2-field::-webkit-inner-spin-button,${R} .qb2-field::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
${R} .qb2-field::placeholder{color:color-mix(in oklch, var(--field-ink) 65%, var(--field));opacity:1}
${R} .qb2-field:focus{outline:none}
${R} .qb2-field:focus-visible{border-color:var(--qb2-focus);box-shadow:0 0 0 3px oklch(from var(--qb2-focus) l c h / .35)}
${R} .qb2-field[aria-invalid='true']{border-color:var(--danger)}
${R} .qb2-field[aria-invalid='true']:focus-visible{box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .3)}
${R} .qb2-field:disabled{cursor:not-allowed;background:color-mix(in oklch, var(--ink) 4%, var(--field))}
${R} .qb2-sb{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px;padding:0;cursor:pointer;border:1px solid var(--button-2-border, transparent);border-radius:var(--button-radius, var(--radius, 12px));background:var(--button-2-bg, var(--secondary));color:var(--button-2-ink, var(--secondary-ink));box-shadow:var(--button-2-shadow, var(--shadow-sm));transition:background .16s ease, transform .16s ease}
${R} .qb2-sb:hover:not(:disabled){background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.04) c h)}
${R} .qb2-sb:active:not(:disabled){transform:translateY(1px);background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.07) c h)}
${R} .qb2-sb:focus-visible{outline:3px solid var(--qb2-focus);outline-offset:2px}
${R} .qb2-sb:disabled{cursor:not-allowed;color:color-mix(in oklch, var(--button-2-ink, var(--secondary-ink)) 45%, var(--button-2-bg, var(--secondary)))}
@media (min-width:480px){${R} .qb2-field{width:6.5rem}}
${R} .qb2-units{padding-left:4px;font-size:1.0625rem;font-weight:600;color:var(--muted)}
${R} .qb2-chip{display:inline-flex;align-items:center;align-self:start;min-height:32px;margin:0;padding:4px 12px;border-radius:999px;white-space:nowrap;background:var(--qb2-fill);color:var(--accent-fill-ink, var(--card));font-size:.875rem;line-height:1.2;font-weight:800;box-shadow:inset 0 1px 0 oklch(from var(--qb2-fill) calc(l + 0.12) c h / .6)}
${R} .qb2-chip[data-flash]{animation:qb2-pop .3s cubic-bezier(.2,.7,.2,1) both}
${R} .qb2-err{margin:8px 0 0;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--danger);text-wrap:pretty}
${R} .qb2-err:empty{display:none}
${R} .qb2-slide{position:relative;margin-top:24px}
${R} .qb2-ticks{position:absolute;top:0;bottom:0;left:var(--qb2-t);right:var(--qb2-t);pointer-events:none}
${R} .qb2-tick{position:absolute;top:50%;width:3px;height:22px;margin:-11px 0 0 -1.5px;border-radius:2px;background:oklch(from var(--ink) l c h / .3)}
${R} .qb2-tick[data-on]{background:oklch(from var(--qb2-fill) calc(l - 0.12) c h)}
${R} .qb2-range{--qb2-rail:color-mix(in oklch, var(--ink) 12%, var(--card));position:relative;z-index:1;display:block;width:100%;height:44px;margin:0;padding:0;background:transparent;-webkit-appearance:none;appearance:none;cursor:pointer}
${R} .qb2-range::-webkit-slider-runnable-track{height:10px;border-radius:999px;background:linear-gradient(to right, var(--qb2-fill) 0 var(--pos), var(--qb2-rail) var(--pos) 100%)}
${R} .qb2-range::-moz-range-track{height:10px;border-radius:999px;background:linear-gradient(to right, var(--qb2-fill) 0 var(--pos), var(--qb2-rail) var(--pos) 100%)}
${R} .qb2-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:28px;height:28px;margin-top:-9px;border-radius:999px;background:var(--card);border:4px solid var(--qb2-fill);box-shadow:0 1px 2px oklch(from var(--qb2-shadow) l c h / .3), 0 4px 8px -2px oklch(from var(--qb2-shadow) l c h / .32);transition:transform .16s ease, box-shadow .16s ease}
${R} .qb2-range::-moz-range-thumb{box-sizing:border-box;width:28px;height:28px;border-radius:999px;background:var(--card);border:4px solid var(--qb2-fill);box-shadow:0 1px 2px oklch(from var(--qb2-shadow) l c h / .3), 0 4px 8px -2px oklch(from var(--qb2-shadow) l c h / .32);transition:transform .16s ease, box-shadow .16s ease}
${R} .qb2-range:hover:not(:disabled)::-webkit-slider-thumb{transform:scale(1.08)}
${R} .qb2-range:hover:not(:disabled)::-moz-range-thumb{transform:scale(1.08)}
${R} .qb2-range:active:not(:disabled)::-webkit-slider-thumb{transform:scale(1.14)}
${R} .qb2-range:active:not(:disabled)::-moz-range-thumb{transform:scale(1.14)}
${R} .qb2-range:focus{outline:none}
${R} .qb2-range:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 4px oklch(from var(--qb2-focus) l c h / .4), 0 1px 2px oklch(from var(--qb2-shadow) l c h / .3)}
${R} .qb2-range:focus-visible::-moz-range-thumb{box-shadow:0 0 0 4px oklch(from var(--qb2-focus) l c h / .4), 0 1px 2px oklch(from var(--qb2-shadow) l c h / .3)}
${R} .qb2-range:disabled{cursor:not-allowed;opacity:.55}
${R} .qb2-ladder{display:grid;padding:0 var(--qb2-t);margin-top:4px}
${R} .qb2-rung{justify-self:start;appearance:none;display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-height:44px;margin:0 0 0 -8px;padding:6px 8px;border:0;border-radius:calc(var(--button-radius, var(--radius, 12px)) * .67);background:transparent;text-align:left;cursor:pointer;font-family:var(--font-body);color:var(--muted);transition:color .16s ease, background .16s ease}
${R} .qb2-rung b{font-size:.9375rem;line-height:1.2;font-weight:800;font-variant-numeric:tabular-nums}
${R} .qb2-rung span{font-size:.875rem;line-height:1.2;font-weight:600;font-variant-numeric:tabular-nums}
${R} .qb2-rung[data-on]{color:var(--ink)}
${R} .qb2-rung[data-current]{color:var(--accent)}
${R} .qb2-rung:hover:not(:disabled){background:var(--button-2-bg, var(--secondary));color:var(--button-2-ink, var(--secondary-ink))}
${R} .qb2-rung:active:not(:disabled){background:oklch(from var(--button-2-bg, var(--secondary)) calc(l - 0.05) c h)}
${R} .qb2-rung:focus-visible{outline:3px solid var(--qb2-focus);outline-offset:0}
${R} .qb2-rung:disabled{cursor:not-allowed}
${R} .qb2-rung[data-flash]{animation:qb2-pop .3s cubic-bezier(.2,.7,.2,1) both}
${R} .qb2-nudge{margin:16px 0 0;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--ink);text-wrap:pretty}
${R} .qb2-nudge strong{font-weight:800}
${R} .qb2-nudge .qb2-ic{color:var(--accent)}
${R} .qb2-reason{margin-top:24px;padding-top:24px;border-top:1px solid oklch(from var(--ink) l c h / .14)}
${R} .qb2-red{margin:0 0 12px;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance;color:var(--qb2-red)}
${R} .qb2-why{margin:0;max-width:64ch;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--muted);text-wrap:pretty}
${R} .qb2-act{grid-area:act;display:grid;gap:12px;min-width:0;padding:clamp(20px,3vw,32px);background:var(--card);color:var(--ink);border:1px solid color-mix(in oklch, var(--accent) 35%, var(--card));border-radius:var(--card-radius, var(--radius, 14px));box-shadow:var(--shadow-lg, 0 2px 4px oklch(from var(--qb2-shadow) l c h / .22), 0 12px 24px -8px oklch(from var(--qb2-shadow) l c h / .32))}
${R} .qb2-anchor{margin:0;text-align:center;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--muted);text-wrap:pretty}
${R} .qb2-anchor strong{font-weight:800;color:var(--ink);font-variant-numeric:tabular-nums}
${R} .qb2-btn{--b:var(--button-bg, var(--cta));--b2:var(--button-bg-2, var(--cta-2));appearance:none;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;width:100%;min-height:72px;padding:12px 28px;border:0;cursor:pointer;text-align:center;
border-radius:var(--button-radius, var(--radius, 12px));color:var(--button-ink, var(--cta-ink));text-shadow:var(--button-text-shadow, none);text-transform:var(--button-case, none);
background:linear-gradient(oklch(from var(--b) calc(l + 0.04) c h), oklch(from var(--b2) calc(l - 0.02) c h));
box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--b) calc(l + 0.14) c h / .7), inset 0 -3px 0 oklch(from var(--b) calc(l - 0.16) c h), 0 1px 2px oklch(from var(--qb2-shadow) l c h / .3), 0 8px 16px -6px oklch(from var(--qb2-shadow) l c h / .4));
transition:background .16s ease, box-shadow .16s ease, transform .16s ease}
${R} .qb2-btn-main{display:inline-flex;align-items:center;justify-content:center;gap:8px;font-family:var(--button-font, var(--font-display));font-weight:var(--button-weight, 800);font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;text-wrap:balance}
${R} .qb2-btn-sub{font-family:var(--font-body);font-size:.9375rem;line-height:1.3;font-weight:600;text-wrap:pretty}
${R} .qb2-btn:hover:not(:disabled),${R}[data-force='hover'] .qb2-btn:not(:disabled){background:linear-gradient(oklch(from var(--b) calc(l - 0.01) c h), oklch(from var(--b2) calc(l - 0.07) c h));box-shadow:inset 0 1px 0 oklch(from var(--b) calc(l + 0.12) c h / .7), inset 0 -3px 0 oklch(from var(--b) calc(l - 0.2) c h), 0 1px 2px oklch(from var(--qb2-shadow) l c h / .34), 0 10px 18px -6px oklch(from var(--qb2-shadow) l c h / .5)}
${R} .qb2-btn:active:not(:disabled),${R}[data-force='active'] .qb2-btn:not(:disabled){transform:translateY(1px);background:linear-gradient(oklch(from var(--b) calc(l - 0.05) c h), oklch(from var(--b2) calc(l - 0.09) c h));box-shadow:inset 0 2px 3px oklch(from var(--b) calc(l - 0.22) c h / .55), inset 0 -2px 0 oklch(from var(--b) calc(l - 0.2) c h), 0 1px 1px oklch(from var(--qb2-shadow) l c h / .3)}
${R} .qb2-btn:focus-visible{outline:3px solid var(--qb2-focus);outline-offset:3px}
${R} .qb2-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:var(--button-2-shadow, var(--shadow-sm))}
${R} .qb2-assure{margin:0;text-align:center;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--muted);text-wrap:pretty}
${R} .qb2-ic--ok{color:var(--success)}
${R} .qb2-aerr{margin:0;text-align:center;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--danger);text-wrap:pretty}
${R} .qb2-spin{animation:qb2-spin .8s linear infinite}
${R} .qb2-rise{animation:qb2-rise .45s cubic-bezier(.2,.7,.2,1) both;animation-delay:var(--d, 0s)}
@keyframes qb2-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes qb2-pop{from{opacity:.82;transform:scale(.9)}to{opacity:1;transform:scale(1)}}
@keyframes qb2-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce){
${R} .qb2-rise,${R} .qb2-chip[data-flash],${R} .qb2-rung[data-flash],${R} .qb2-spin{animation:none}
${R} .qb2-btn,${R} .qb2-sb,${R} .qb2-rung,${R} .qb2-field{transition:none}
${R} .qb2-range::-webkit-slider-thumb{transition:none}
${R} .qb2-range::-moz-range-thumb{transition:none}
${R} .qb2-range:hover:not(:disabled)::-webkit-slider-thumb,${R} .qb2-range:active:not(:disabled)::-webkit-slider-thumb{transform:none}
${R} .qb2-range:hover:not(:disabled)::-moz-range-thumb,${R} .qb2-range:active:not(:disabled)::-moz-range-thumb{transform:none}
}
`
pieces/offer/quantity-breaks-2/specimen.tsx 37 lines
import __studioImagee79cd144 from "../assets/a2b19c60b6ec23e1.webp";
import { QuantityBreaks2 } from '../quantity-breaks-2'
import type { QuantityBreaks2State } from '../quantity-breaks-2'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function QuantityBreaks2Specimen({ state = 'default' }: { state?: QuantityBreaks2State }) {
return (
<QuantityBreaks2
state={state}
heading='Kit out the whole team and the price per notebook drops'
highlight='the price per notebook drops'
lead='Slide to your team size. Every notch you pass lowers the price of every notebook in the order.'
productName='Brightpath custom team notebooks'
productNote='Your logo on the cover · A5 · 160 pages'
productImage={slot('product', __studioImagee79cd144)}
productImageAlt='A stack of Brightpath custom team notebooks in navy, coral and sage'
unit='notebook'
unitPlural='notebooks'
breaks={[
{ min: 1, price: 24, label: 'Single' },
{ min: 10, price: 21, label: 'Team pack' },
{ min: 25, price: 18, label: 'Squad' },
{ min: 50, price: 15, label: 'Department' },
{ min: 100, price: 12, label: 'Company-wide' },
]}
max={250}
defaultQuantity={20}
currency='USD'
reasonTitle='Why bigger orders cost less per notebook'
reasonText='Setting up your cover art and the press takes the same time for 10 notebooks or 100. Order more at once and that setup is shared across every notebook, so each one costs you less.'
reassurance={defaults.sample.guarantee}
/>
)
}
| Name | Type | Details |
|---|---|---|
heading OptionalQuantityBreaks2 |
string |
Default 'Kit out the whole team and the price per notebook drops'
|
highlight OptionalQuantityBreaks2 |
string |
Default 'the price per notebook drops'
|
lead OptionalQuantityBreaks2 |
string |
Default 'Slide to your team size. Every notch you pass lowers the price of every notebook in the order.'
|
productName OptionalQuantityBreaks2 |
string |
Default 'Brightpath custom team notebooks'
|
productNote OptionalQuantityBreaks2 |
string |
Default 'Your logo on the cover · A5 · 160 pages'
|
productImage OptionalQuantityBreaks2 |
string |
|
productImageAlt OptionalQuantityBreaks2 |
string |
Default ''
|
unit OptionalQuantityBreaks2 |
string |
Default 'notebook'
|
unitPlural OptionalQuantityBreaks2 |
string |
|
breaks OptionalQuantityBreaks2 |
QuantityBreaks2Break[] |
Default DEFAULT_BREAKS
|
singlePrice OptionalQuantityBreaks2 |
number |
|
min OptionalQuantityBreaks2 |
number |
|
max OptionalQuantityBreaks2 |
number |
Default 250
|
defaultQuantity OptionalQuantityBreaks2 |
number |
|
currency OptionalQuantityBreaks2 |
string |
Default 'USD'
|
locale OptionalQuantityBreaks2 |
string |
Default 'en-US'
|
reasonTitle OptionalQuantityBreaks2 |
string |
Default 'Why bigger orders cost less per notebook'
|
reasonText OptionalQuantityBreaks2 |
string |
Default 'Setting up your cover art and the press takes the same time for 10 notebooks or 100. Order more at once and that setup is shared across every notebook, so each one costs you less.'
|
reassurance OptionalQuantityBreaks2 |
string |
Default ''
|
copy OptionalQuantityBreaks2 |
Partial<QuantityBreaks2Copy> |
|
state OptionalQuantityBreaks2 |
QuantityBreaks2State |
Default 'default'
|
onSubmit OptionalQuantityBreaks2 |
(order: QuantityBreaks2Order) => void | Promise<void> |
|
className OptionalQuantityBreaks2 |
string |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-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).
-
a2b19c60b6ec23e1.webp
image/webp · 78.9 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB