Roi Calculator 2
Cost-of-waiting ledger: the visitor's own power bill and wait, itemised live into what doing nothing sends the
Use it in a prompt
Use content/roi-calculator-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/content/roi-calculator-2.tsx. - Import it and pass your copy and images (Props tab):
import { RoiCalculator2 } from "@/components/funneldna/content/roi-calculator-2"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/content/roi-calculator-2/component.tsx 599 lines
// layout: ledger-receipt
// Cost-of-waiting ledger: the visitor's own power bill and wait, itemised live into what doing nothing sends the
// utility, ruled off to a bold total that ends in the free-quote action. Always an estimate, never a promised saving.
import * as React from 'react'
import { AlertCircle, Info, Receipt } from 'lucide-react'
export type RoiCalculator2Values = {
/** The monthly bill as the visitor entered it */
monthlyBill: number | null
/** Months the visitor plans to wait */
months: number | null
/** The same monthly bill a year out at the supplied average rise */
billNextYear: number | null
/** Paid to the utility over the next 12 months */
yearTotal: number | null
/** Extra paid over the wait because of the rate rise */
riseOverWait: number | null
/** Paid to the utility over the chosen wait */
totalOverWait: number | null
}
export type RoiCalculator2Copy = {
ledgerTitle: string
/** Placeholder: {business} */
preparedBy: string
liveChip: string
billLabel: string
billPlaceholder: string
billHint: string
/** Placeholders: {min}, {max} */
billError: string
monthsLabel: string
monthsPlaceholder: string
monthsSuffix: string
/** Placeholders: {min}, {max} */
monthsHint: string
/** Placeholders: {min}, {max} */
monthsError: string
sliderLabel: string
rowBill: string
/** Placeholder: {rate} */
rowNextYear: string
rowYear: string
/** Placeholders: {months}, {monthWord} */
rowRise: string
/** Placeholders: {months}, {monthWord} */
totalLabel: string
perMonth: string
increasePrefix: string
monthSingular: string
monthPlural: string
emptyAmount: string
invalidNote: string
/** Placeholder: {rate} */
estimateNote: string
/** Shown in the phone sticky bar. Placeholders: {months}, {monthWord} */
stickyLabel: string
}
export type RoiCalculator2Props = {
/** Big headline; emphasise one phrase with <span className='rc2-em'> */
headline?: React.ReactNode
lead?: React.ReactNode
/** One-sentence punch lines under the lead; keep the last one a single word */
punchLines?: string[]
/** Shown as 'Prepared by …' on the ledger; leave empty to hide */
businessName?: string
/** Slot: scene. Photo offset behind the ledger */
sceneImage?: string
sceneImageAlt?: string
/** The business's own average yearly utility rate rise, in percent */
rateRise?: number
/** Starting monthly bill */
startBill?: number
/** Starting months of waiting */
startMonths?: number
billMin?: number
billMax?: number
monthsMin?: number
monthsMax?: number
/** ISO currency used to format money */
currency?: string
/** Symbol shown inside the bill field */
currencySymbol?: string
locale?: string
buttonLabel?: string
/** One plain line under the button */
secondaryLine?: string
/** Optional destination for the secondary line */
secondaryHref?: string
href?: string
onAction?: (values: RoiCalculator2Values) => void
disabled?: boolean
state?: 'default' | 'hover' | 'active' | 'disabled' | 'error'
copy?: Partial<RoiCalculator2Copy>
className?: string
}
type Fields = { bill: string; months: string }
type Touched = { bill: boolean; months: boolean }
const DEFAULT_COPY: RoiCalculator2Copy = {
ledgerTitle: 'Your cost-of-waiting ledger',
preparedBy: 'Prepared by {business}',
liveChip: 'Updates as you type',
billLabel: 'Monthly power bill',
billPlaceholder: '180',
billHint: 'Use last month’s bill.',
billError: 'Enter your monthly bill, from {min} to {max}.',
monthsLabel: 'Months you’ll wait',
monthsPlaceholder: '12',
monthsSuffix: 'months',
monthsHint: 'Drag or type, {min} to {max}.',
monthsError: 'Choose {min} to {max} months.',
sliderLabel: 'Months of waiting',
rowBill: 'Your bill this month',
rowNextYear: 'Your bill a year from now, at our {rate}% average rise',
rowYear: 'Paid to the utility over the next year',
rowRise: 'Extra from rate rises during {months} {monthWord}',
totalLabel: 'What waiting {months} {monthWord} costs you',
perMonth: '/mo',
increasePrefix: '+',
monthSingular: 'month',
monthPlural: 'months',
emptyAmount: '—',
invalidNote: 'Fix the highlighted number to finish your ledger.',
estimateNote: 'Estimate based on your numbers and our average {rate}% yearly rate rise. Your real bills will vary. This is not a promised saving.',
stickyLabel: '{months} {monthWord} of waiting',
}
const DEFAULT_HEADLINE = (
<>
Waiting has a price. <span className='rc2-em'>Here’s your bill.</span>
</>
)
const DEFAULT_PUNCH = ['Every month you wait, the utility sends a bill.', 'Then the rate goes up.', 'Again.']
export function RoiCalculator2(props: RoiCalculator2Props) {
const {
headline = DEFAULT_HEADLINE,
lead = 'Enter your monthly power bill and how long you’re thinking it over. The ledger adds up what you’ll pay the utility while you wait.',
punchLines = DEFAULT_PUNCH,
businessName = '',
sceneImage,
sceneImageAlt = '',
rateRise = 4,
startBill = 180,
startMonths = 12,
billMin = 20,
billMax = 2000,
monthsMin = 1,
monthsMax = 36,
currency = 'USD',
currencySymbol = '$',
locale = 'en-US',
buttonLabel = 'Get My Free Quote',
secondaryLine = 'or keep scrolling to see how your quote works',
secondaryHref,
href,
onAction,
disabled = false,
state = 'default',
copy: copyOverrides,
className,
} = props
const copy: RoiCalculator2Copy = { ...DEFAULT_COPY, ...copyOverrides }
const uid = React.useId()
const titleId = `${uid}-title`
const ledgerId = `${uid}-ledger`
const billId = `${uid}-bill`
const billHintId = `${uid}-bill-hint`
const billErrId = `${uid}-bill-error`
const monthsId = `${uid}-months`
const monthsHintId = `${uid}-months-hint`
const monthsErrId = `${uid}-months-error`
const billRef = React.useRef<HTMLInputElement>(null)
const monthsRef = React.useRef<HTMLInputElement>(null)
const startFields = (s: RoiCalculator2Props['state']): Fields =>
s === 'error' ? { bill: '', months: String(monthsMax + 12) } : { bill: String(startBill), months: String(startMonths) }
const [fields, setFields] = React.useState<Fields>(() => startFields(state))
const [touched, setTouched] = React.useState<Touched>(() => ({ bill: state === 'error', months: state === 'error' }))
React.useEffect(() => {
setFields(startFields(state))
setTouched({ bill: state === 'error', months: state === 'error' })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
const isDisabled = disabled || state === 'disabled'
const money = React.useMemo(
() => new Intl.NumberFormat(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 }),
[locale, currency],
)
const plain = React.useMemo(() => new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }), [locale])
const bill = parseNumber(fields.bill, currencySymbol)
const billOk = bill !== null && bill >= billMin && bill <= billMax
const months = parseWhole(fields.months)
const monthsOk = months !== null && months >= monthsMin && months <= monthsMax
const result = bill !== null && months !== null && billOk && monthsOk ? costOfWaiting(bill, months, rateRise) : null
const showBillError = !billOk && (touched.bill || fields.bill.trim() !== '')
const showMonthsError = !monthsOk && (touched.months || fields.months.trim() !== '')
const sliderValue = clamp(months ?? startMonths, monthsMin, monthsMax)
const fillPct = monthsMax > monthsMin ? ((sliderValue - monthsMin) / (monthsMax - monthsMin)) * 100 : 100
const labelMonths = monthsOk && months !== null ? months : sliderValue
const monthWord = labelMonths === 1 ? copy.monthSingular : copy.monthPlural
const monthVars = { months: String(labelMonths), monthWord }
const rate = plain.format(rateRise)
const totalText = result ? money.format(result.total) : ''
const rows: { key: string; label: string; amount: string | null; suffix?: string }[] = [
{ key: 'bill', label: copy.rowBill, amount: result && bill !== null ? money.format(bill) : null, suffix: copy.perMonth },
{ key: 'next', label: fill(copy.rowNextYear, { rate }), amount: result ? money.format(result.nextYear) : null, suffix: copy.perMonth },
{ key: 'year', label: copy.rowYear, amount: result ? money.format(result.year) : null },
{ key: 'rise', label: fill(copy.rowRise, monthVars), amount: result ? copy.increasePrefix + money.format(result.rise) : null },
]
const values: RoiCalculator2Values = {
monthlyBill: billOk ? bill : null,
months: monthsOk ? months : null,
billNextYear: result ? round2(result.nextYear) : null,
yearTotal: result ? round2(result.year) : null,
riseOverWait: result ? round2(result.rise) : null,
totalOverWait: result ? round2(result.total) : null,
}
const runAction = (): boolean => {
if (isDisabled) return false
if (!result) {
setTouched({ bill: true, months: true })
const target = billOk ? monthsRef : billRef
target.current?.focus()
return false
}
onAction?.(values)
return true
}
const forced = state === 'hover' || state === 'active' ? state : undefined
const rootClass = ['cf-roi-calculator-2', className].filter(Boolean).join(' ')
return (
<section className={rootClass} aria-labelledby={titleId}>
<style>{CSS}</style>
<div className='rc2-wrap'>
<div className='rc2-copy'>
<h2 id={titleId} className='rc2-h2'>
{headline}
</h2>
{lead ? <p className='rc2-lead'>{lead}</p> : null}
{punchLines.length ? (
<div className='rc2-punch'>
{punchLines.map((line, i) => (
<p key={i}>{line}</p>
))}
</div>
) : null}
</div>
<div className={`rc2-stage${sceneImage ? ' has-photo' : ''}`}>
{sceneImage ? (
<img className='rc2-photo' src={sceneImage} alt={sceneImageAlt} width={900} height={675} decoding='async' />
) : null}
<form
className='rc2-card'
noValidate
aria-labelledby={ledgerId}
onSubmit={(e) => {
e.preventDefault()
runAction()
}}
>
<div className='rc2-head'>
<span className='rc2-disc' aria-hidden='true'>
<Receipt size={20} strokeWidth={2.5} />
</span>
<div className='rc2-headtext'>
<h3 id={ledgerId} className='rc2-h3'>
{copy.ledgerTitle}
</h3>
{businessName ? <p className='rc2-by'>{fill(copy.preparedBy, { business: businessName })}</p> : null}
</div>
<span className='rc2-chip'>{copy.liveChip}</span>
</div>
<div className='rc2-well'>
<div className='rc2-field'>
<label className='rc2-label' htmlFor={billId}>
{copy.billLabel}
</label>
<div className='rc2-control'>
{currencySymbol ? (
<span className='rc2-affix rc2-prefix' aria-hidden='true'>
{currencySymbol}
</span>
) : null}
<input
ref={billRef}
id={billId}
className='rc2-input'
type='text'
inputMode='decimal'
autoComplete='off'
placeholder={copy.billPlaceholder}
value={fields.bill}
disabled={isDisabled}
aria-invalid={showBillError}
aria-describedby={showBillError ? billErrId : billHintId}
onChange={(e) => {
const next = e.target.value
setFields((f) => ({ ...f, bill: next }))
}}
onBlur={() => setTouched((t) => ({ ...t, bill: true }))}
/>
</div>
{showBillError ? (
<p id={billErrId} className='rc2-error'>
<AlertCircle size={16} strokeWidth={2.5} aria-hidden='true' />
{fill(copy.billError, { min: money.format(billMin), max: money.format(billMax) })}
</p>
) : (
<p id={billHintId} className='rc2-hint'>
{copy.billHint}
</p>
)}
</div>
<div className='rc2-field'>
<label className='rc2-label' htmlFor={monthsId}>
{copy.monthsLabel}
</label>
<div className='rc2-control'>
<input
ref={monthsRef}
id={monthsId}
className='rc2-input has-suffix'
type='text'
inputMode='numeric'
autoComplete='off'
placeholder={copy.monthsPlaceholder}
value={fields.months}
disabled={isDisabled}
aria-invalid={showMonthsError}
aria-describedby={showMonthsError ? monthsErrId : monthsHintId}
onChange={(e) => {
const next = e.target.value
setFields((f) => ({ ...f, months: next }))
}}
onBlur={() => setTouched((t) => ({ ...t, months: true }))}
/>
<span className='rc2-affix rc2-suffix' aria-hidden='true'>
{copy.monthsSuffix}
</span>
</div>
<input
className='rc2-range'
type='range'
min={monthsMin}
max={monthsMax}
step={1}
value={sliderValue}
disabled={isDisabled}
aria-label={copy.sliderLabel}
aria-valuetext={`${sliderValue} ${sliderValue === 1 ? copy.monthSingular : copy.monthPlural}`}
style={{ '--rc2-fill': `${fillPct}%` } as React.CSSProperties}
onChange={(e) => {
const next = e.target.value
setFields((f) => ({ ...f, months: next }))
}}
/>
{showMonthsError ? (
<p id={monthsErrId} className='rc2-error'>
<AlertCircle size={16} strokeWidth={2.5} aria-hidden='true' />
{fill(copy.monthsError, { min: String(monthsMin), max: String(monthsMax) })}
</p>
) : (
<p id={monthsHintId} className='rc2-hint'>
{fill(copy.monthsHint, { min: String(monthsMin), max: String(monthsMax) })}
</p>
)}
</div>
</div>
<ul className='rc2-lines'>
{rows.map((row) => (
<li className='rc2-row' key={row.key}>
<span className='rc2-row-label'>{row.label}</span>
<span className='rc2-leader' aria-hidden='true' />
<span className={`rc2-row-amount${row.amount ? '' : ' is-empty'}`}>
{row.amount ? (
<span key={row.amount} className='rc2-pop'>
{row.amount}
{row.suffix ? <small>{row.suffix}</small> : null}
</span>
) : (
copy.emptyAmount
)}
</span>
</li>
))}
</ul>
<div className='rc2-total'>
<span className='rc2-total-label'>{fill(copy.totalLabel, monthVars)}</span>
<output className={`rc2-total-amount${result ? '' : ' is-empty'}`} htmlFor={`${billId} ${monthsId}`} aria-live='polite'>
{result ? (
<span key={totalText} className='rc2-pop'>
{totalText}
</span>
) : (
copy.emptyAmount
)}
</output>
</div>
{result ? null : <p className='rc2-invalid'>{copy.invalidNote}</p>}
<p className='rc2-note'>
<Info size={16} strokeWidth={2.5} aria-hidden='true' />
{fill(copy.estimateNote, { rate })}
</p>
<div className='rc2-action'>
{result ? (
<p className='rc2-sticky-total' aria-hidden='true'>
<span>{fill(copy.stickyLabel, monthVars)}</span>
<strong>{totalText}</strong>
</p>
) : null}
{href && !isDisabled ? (
<a
className='rc2-btn'
href={href}
data-force={forced}
onClick={(e) => {
if (!runAction()) e.preventDefault()
}}
>
{buttonLabel}
</a>
) : (
<button className='rc2-btn' type='submit' disabled={isDisabled} data-force={forced}>
{buttonLabel}
</button>
)}
{secondaryLine ? (
<p className='rc2-quiet'>{secondaryHref ? <a href={secondaryHref}>{secondaryLine}</a> : secondaryLine}</p>
) : null}
</div>
</form>
</div>
</div>
</section>
)
}
export default RoiCalculator2
function fill(template: string, vars: Record<string, string>): string {
return template.replace(/\{(\w+)\}/g, (match: string, key: string) => (key in vars ? vars[key] : match))
}
function parseNumber(raw: string, symbol: string): number | null {
const clean = (symbol ? raw.split(symbol).join('') : raw).replace(/[\s,]/g, '')
if (!/^\d+(\.\d+)?$/.test(clean)) return null
return Number(clean)
}
function parseWhole(raw: string): number | null {
const clean = raw.trim()
if (!/^\d+$/.test(clean)) return null
return Number(clean)
}
function clamp(n: number, min: number, max: number): number {
return Math.min(max, Math.max(min, n))
}
function round2(n: number): number {
return Math.round(n * 100) / 100
}
/** Bills compound monthly at the supplied yearly rise; returns what the utility is paid, not any saving. */
function costOfWaiting(bill: number, months: number, ratePct: number) {
const g = Math.pow(1 + ratePct / 100, 1 / 12)
const sum = (n: number) => (Math.abs(g - 1) < 1e-9 ? bill * n : (bill * (Math.pow(g, n) - 1)) / (g - 1))
const total = sum(months)
return { nextYear: bill * (1 + ratePct / 100), year: sum(12), rise: Math.max(0, total - bill * months), total }
}
const R = '.cf-roi-calculator-2'
const SHADOW = 'var(--rc2-shadow)'
const BTN = 'var(--button-bg,var(--cta))'
const BTN2 = 'var(--button-bg-2,var(--cta-2))'
const CSS = `
${R}{--rc2-shadow:var(--shadow,oklch(0.22 0.03 260));--rc2-marker:var(--marker,#fae37c);--rc2-focus:var(--field-focus,var(--accent));position:relative;width:100%;box-sizing:border-box;padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) clamp(64px,8.5vw,120px);background:var(--surface);color:var(--ink);font-family:var(--font-body);font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;overflow-x:clip}
${R} *,${R} *::before,${R} *::after{box-sizing:border-box}
${R} .rc2-wrap{max-width:1120px;margin:0 auto;display:grid;grid-template-columns:minmax(0,.92fr) minmax(0,1.08fr);gap:clamp(32px,5vw,72px);align-items:start}
${R} .rc2-copy{position:sticky;top:32px;padding-top:8px;min-width:0}
${R} .rc2-h2{margin:0 0 16px;font-family:var(--font-display);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);color:var(--ink);text-wrap:balance}
${R} .rc2-em{color:oklch(from var(--rc2-marker) 0.2 0.03 h);background-image:linear-gradient(177deg,transparent 0 9%,var(--rc2-marker) 9% 95%,transparent 95%);background-repeat:no-repeat;padding:0 .12em;margin:0 -.04em;border-radius:.12em .32em .2em .36em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
${R} .rc2-lead{margin:0 0 32px;max-width:34rem;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .rc2-punch p{margin:0 0 8px;font-weight:700;color:var(--ink);text-wrap:pretty}
${R} .rc2-punch p:last-child{margin:12px 0 0;font-family:var(--font-display);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;font-weight:var(--display-weight,800);letter-spacing:-0.01em}
${R} .rc2-stage{position:relative;min-width:0}
${R} .rc2-stage.has-photo{padding-top:168px}
${R} .rc2-photo{position:absolute;top:0;right:0;display:block;width:78%;height:360px;object-fit:cover;object-position:center 45%;border-radius:12px}
${R} .rc2-card{--rc2-pad:clamp(20px,3vw,32px);position:relative;width:100%;margin:0;padding:var(--rc2-pad);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-lg,0 2px 4px oklch(from ${SHADOW} l c h / .22),0 12px 24px -8px oklch(from ${SHADOW} l c h / .32)))}
${R} .has-photo .rc2-card{width:88%}
${R} .rc2-head{display:flex;align-items:center;gap:12px;margin:0 0 24px}
${R} .rc2-disc{flex:none;display:grid;place-items:center;width:40px;height:40px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card))}
${R} .rc2-headtext{flex:1 1 auto;min-width:0}
${R} .rc2-h3{margin:0;font-family:var(--font-display);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);color:var(--ink);text-wrap:balance}
${R} .rc2-by{margin:4px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted)}
${R} .rc2-chip{flex:none;display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;background:color-mix(in oklch,var(--ink) 6%,var(--card));color:var(--ink);font-size:.875rem;line-height:1.2;font-weight:800;white-space:nowrap}
${R} .rc2-well{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;align-items:start;margin:0 0 16px;padding:16px;border-radius:10px;background:color-mix(in oklch,var(--ink) 4%,var(--card))}
${R} .rc2-field{min-width:0}
${R} .rc2-label{display:block;margin:0 0 8px;font-size:1rem;line-height:1.25;font-weight:700;color:var(--label-ink,var(--ink))}
${R} .rc2-control{position:relative}
${R} .rc2-input{display:block;width:100%;height:56px;margin:0;padding:0 16px 0 2.25rem;border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));background:var(--field);color:var(--field-ink);font-family:var(--font-body);font-size:1.0625rem;font-weight:700;font-variant-numeric:tabular-nums;outline:none;-webkit-appearance:none;appearance:none;transition:border-color .16s ease,box-shadow .16s ease}
${R} .rc2-input.has-suffix{padding:0 5.5rem 0 16px}
${R} .rc2-input::placeholder{color:color-mix(in oklch,var(--field-ink) 65%,var(--field));opacity:1;font-weight:500}
${R} .rc2-input:hover:not(:disabled){border-color:color-mix(in oklch,var(--ink) 42%,transparent)}
${R} .rc2-input:focus{border-color:var(--rc2-focus);box-shadow:0 0 0 3px oklch(from var(--rc2-focus) l c h / .35)}
${R} .rc2-input[aria-invalid='true']{border-color:var(--danger)}
${R} .rc2-input[aria-invalid='true']:focus{box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .3)}
${R} .rc2-input:disabled{cursor:not-allowed;opacity:.62}
${R} .rc2-affix{position:absolute;top:50%;transform:translateY(-50%);font-size:1.0625rem;line-height:1;font-weight:700;color:color-mix(in oklch,var(--field-ink) 65%,var(--field));pointer-events:none}
${R} .rc2-prefix{left:16px}
${R} .rc2-suffix{right:16px;font-weight:600}
${R} .rc2-hint{margin:8px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .rc2-error{margin:8px 0 0;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--danger);text-wrap:pretty}
${R} .rc2-error svg,${R} .rc2-note svg{display:inline-block;vertical-align:-.15em;margin-inline-end:.4em}
${R} .rc2-range{display:block;width:100%;height:32px;margin:8px 0 0;padding:0;background:transparent;cursor:pointer;-webkit-appearance:none;appearance:none}
${R} .rc2-range::-webkit-slider-runnable-track{height:8px;border-radius:999px;background:linear-gradient(to right,var(--accent-fill,var(--accent)) 0 var(--rc2-fill,50%),color-mix(in oklch,var(--ink) 16%,var(--card)) var(--rc2-fill,50%) 100%)}
${R} .rc2-range::-moz-range-track{height:8px;border-radius:999px;background:linear-gradient(to right,var(--accent-fill,var(--accent)) 0 var(--rc2-fill,50%),color-mix(in oklch,var(--ink) 16%,var(--card)) var(--rc2-fill,50%) 100%)}
${R} .rc2-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:28px;height:28px;margin-top:-10px;border-radius:999px;border:3px solid var(--accent-fill,var(--accent));background:var(--card);box-shadow:0 1px 2px oklch(from var(--rc2-shadow) l c h / .3),0 4px 8px -3px oklch(from var(--rc2-shadow) l c h / .35);transition:box-shadow .16s ease,transform .16s ease}
${R} .rc2-range::-moz-range-thumb{width:22px;height:22px;border-radius:999px;border:3px solid var(--accent-fill,var(--accent));background:var(--card);box-shadow:0 1px 2px oklch(from var(--rc2-shadow) l c h / .3),0 4px 8px -3px oklch(from var(--rc2-shadow) l c h / .35);transition:box-shadow .16s ease,transform .16s ease}
${R} .rc2-range:hover:not(:disabled)::-webkit-slider-thumb{transform:scale(1.06)}
${R} .rc2-range:hover:not(:disabled)::-moz-range-thumb{transform:scale(1.06)}
${R} .rc2-range:active:not(:disabled)::-webkit-slider-thumb{transform:scale(.96)}
${R} .rc2-range:focus{outline:none}
${R} .rc2-range:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 4px oklch(from var(--rc2-focus) l c h / .42),0 1px 2px oklch(from var(--rc2-shadow) l c h / .3)}
${R} .rc2-range:focus-visible::-moz-range-thumb{box-shadow:0 0 0 4px oklch(from var(--rc2-focus) l c h / .42),0 1px 2px oklch(from var(--rc2-shadow) l c h / .3)}
${R} .rc2-range:disabled{cursor:not-allowed;opacity:.55}
${R} .rc2-lines{list-style:none;margin:0;padding:0}
${R} .rc2-row{display:flex;align-items:flex-end;gap:8px;margin:0;padding:12px 0}
${R} .rc2-row-label{flex:0 1 auto;min-width:0;font-weight:500;line-height:1.5;color:var(--ink);text-wrap:pretty}
${R} .rc2-leader{flex:1 1 24px;min-width:24px;height:3px;margin-bottom:.42em;background-image:radial-gradient(circle,oklch(from var(--ink) l c h / .42) 0 1.1px,transparent 1.6px);background-size:8px 3px;background-repeat:repeat-x;background-position:left center}
${R} .rc2-row-amount{flex:none;white-space:nowrap;font-family:var(--font-display);font-weight:800;line-height:1.5;font-variant-numeric:tabular-nums;color:var(--ink)}
${R} .rc2-row-amount small{margin-left:2px;font-family:var(--font-body);font-size:.9375rem;font-weight:600;color:var(--muted)}
${R} .rc2-row-amount.is-empty{color:var(--muted)}
${R} .rc2-total{display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px 16px;margin:8px 0 0;padding:16px 0 0;border-top:3px double var(--ink)}
${R} .rc2-total-label{flex:1 1 12rem;min-width:0;font-family:var(--font-display);font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.2;font-weight:800;color:var(--ink);text-wrap:balance}
${R} .rc2-total-amount{display:block;margin-left:auto;font-family:var(--font-display);font-size:clamp(2.5rem,4.2vw,3.75rem);line-height:1;font-weight:var(--display-weight,800);letter-spacing:-0.03em;font-variant-numeric:tabular-nums;color:var(--danger);white-space:nowrap}
${R} .rc2-total-amount.is-empty{color:var(--muted)}
${R} .rc2-invalid{margin:12px 0 0;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--ink)}
${R} .rc2-note{margin:16px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .rc2-action{margin:24px 0 0}
${R} .rc2-sticky-total{display:none;align-items:baseline;justify-content:space-between;gap:12px;margin:0 0 8px;font-size:.9375rem;line-height:1.3;font-weight:700;color:var(--ink)}
${R} .rc2-sticky-total strong{font-family:var(--font-display);font-weight:800;font-variant-numeric:tabular-nums;color:var(--danger);white-space:nowrap}
${R} .rc2-btn{display:flex;align-items:center;justify-content:center;width:100%;min-height:64px;margin:0;padding:12px 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from ${BTN} calc(l + .04) c h),oklch(from ${BTN2} calc(l - .02) c h));color:var(--button-ink,var(--cta-ink));font-family:var(--button-font,var(--font-display));font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;font-weight:var(--button-weight,800);text-transform:var(--button-case,none);text-align:center;text-decoration:none;text-shadow:var(--button-text-shadow,none);text-wrap:balance;cursor:pointer;-webkit-tap-highlight-color:transparent;box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from ${BTN} calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from ${BTN} calc(l - .16) c h),0 1px 2px oklch(from ${SHADOW} l c h / .3),0 8px 16px -6px oklch(from ${SHADOW} l c h / .42));transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
${R} .rc2-btn:hover:not(:disabled),${R} .rc2-btn[data-force='hover']{transform:translateY(-1px);background:linear-gradient(oklch(from ${BTN} calc(l - .01) c h),oklch(from ${BTN2} calc(l - .07) c h));box-shadow:inset 0 1px 0 oklch(from ${BTN} calc(l + .1) c h / .6),inset 0 -3px 0 oklch(from ${BTN} calc(l - .2) c h),0 1px 2px oklch(from var(--rc2-shadow) l c h / .32),0 12px 20px -8px oklch(from var(--rc2-shadow) l c h / .5)}
${R} .rc2-btn:active:not(:disabled),${R} .rc2-btn[data-force='active']{transform:translateY(1px);background:linear-gradient(oklch(from ${BTN} calc(l - .05) c h),oklch(from ${BTN2} calc(l - .08) c h));box-shadow:inset 0 2px 4px oklch(from ${BTN} calc(l - .24) c h / .55),inset 0 -2px 0 oklch(from ${BTN} calc(l - .16) c h),0 1px 1px oklch(from var(--rc2-shadow) l c h / .3)}
${R} .rc2-btn:focus-visible{outline:3px solid var(--rc2-focus);outline-offset:3px}
${R} .rc2-btn:disabled{cursor:not-allowed;transform:none;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} .rc2-quiet{margin:12px 0 0;text-align:center;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted);text-wrap:pretty}
${R} .rc2-quiet a{color:inherit;text-decoration:underline;text-decoration-color:oklch(from var(--muted) l c h / .5);text-underline-offset:.18em}
${R} .rc2-quiet a:hover{color:var(--ink);text-decoration-color:currentColor}
${R} .rc2-quiet a:focus-visible{outline:3px solid var(--rc2-focus);outline-offset:2px;border-radius:4px}
@keyframes rc2-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes rc2-pop{from{opacity:.82;transform:scale(.94)}to{opacity:1;transform:none}}
${R} .rc2-copy>*,${R} .rc2-photo,${R} .rc2-card{animation:rc2-rise .45s cubic-bezier(.2,.7,.2,1) both}
${R} .rc2-copy>:nth-child(2),${R} .rc2-photo{animation-delay:.07s}
${R} .rc2-copy>:nth-child(3),${R} .rc2-card{animation-delay:.14s}
${R} .rc2-pop{display:inline-block;transform-origin:right bottom;animation:rc2-pop .3s cubic-bezier(.2,.7,.2,1) both}
@media (max-width:960px){
${R} .rc2-wrap{grid-template-columns:minmax(0,1fr);max-width:640px}
${R} .rc2-copy{position:static;padding-top:0}
${R} .rc2-stage.has-photo{padding-top:0}
${R} .rc2-photo{position:static;width:100%;height:clamp(200px,48vw,300px)}
${R} .has-photo .rc2-card{width:100%;margin-top:-48px}
}
@media (max-width:640px){
${R} .rc2-well{grid-template-columns:minmax(0,1fr)}
${R} .rc2-chip{display:none}
${R} .rc2-action{position:sticky;bottom:0;z-index:2;margin:24px calc(-1 * var(--rc2-pad)) calc(-1 * var(--rc2-pad));padding:12px var(--rc2-pad) calc(12px + env(safe-area-inset-bottom,0px));background:var(--card);border-top:1px solid oklch(from var(--ink) l c h / .12);border-radius:0 0 var(--card-radius,var(--radius,14px)) var(--card-radius,var(--radius,14px));box-shadow:0 -1px 2px oklch(from var(--rc2-shadow) l c h / .12),0 -8px 16px -10px oklch(from var(--rc2-shadow) l c h / .35)}
${R} .rc2-sticky-total{display:flex}
${R} .rc2-quiet{margin-top:8px}
}
@media (prefers-reduced-motion:reduce){
${R} *,${R} *::before,${R} *::after{animation:none!important;transition:none!important}
}
`
pieces/content/roi-calculator-2/specimen.tsx 32 lines
import __studioImage4075d3a2 from "../assets/bd2c80a4229e6163.webp";
// Specimen: Brightroof Solar's cost-of-waiting ledger, with fictional rates.
import * as React from 'react'
import { RoiCalculator2, type RoiCalculator2Props } from '../roi-calculator-2'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
export default function RoiCalculator2Specimen({ state = 'default' }: { state?: RoiCalculator2Props['state'] }) {
return (
<RoiCalculator2
state={state}
headline={
<>
Waiting on solar has a price. <span className='rc2-em'>Here’s your bill.</span>
</>
}
lead='Enter your monthly power bill and how long you’re thinking it over. The ledger adds up what you’ll pay the utility while you wait.'
businessName='Brightroof Solar'
rateRise={4.5}
startBill={185}
startMonths={12}
buttonLabel='Get My Free Solar Quote'
secondaryLine='or keep scrolling to see how a Brightroof quote works'
sceneImage={slot(
'scene',
__studioImage4075d3a2,
)}
sceneImageAlt='Solar panels on the roof of a sunlit suburban home'
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalRoiCalculator2 |
React.ReactNode |
|
lead OptionalRoiCalculator2 |
React.ReactNode |
|
punchLines OptionalRoiCalculator2 |
string[] |
|
businessName OptionalRoiCalculator2 |
string |
|
sceneImage OptionalRoiCalculator2 |
string |
|
sceneImageAlt OptionalRoiCalculator2 |
string |
|
rateRise OptionalRoiCalculator2 |
number |
|
startBill OptionalRoiCalculator2 |
number |
|
startMonths OptionalRoiCalculator2 |
number |
|
billMin OptionalRoiCalculator2 |
number |
|
billMax OptionalRoiCalculator2 |
number |
|
monthsMin OptionalRoiCalculator2 |
number |
|
monthsMax OptionalRoiCalculator2 |
number |
|
currency OptionalRoiCalculator2 |
string |
|
currencySymbol OptionalRoiCalculator2 |
string |
|
locale OptionalRoiCalculator2 |
string |
|
buttonLabel OptionalRoiCalculator2 |
string |
|
secondaryLine OptionalRoiCalculator2 |
string |
|
secondaryHref OptionalRoiCalculator2 |
string |
|
href OptionalRoiCalculator2 |
string |
|
onAction OptionalRoiCalculator2 |
(values: RoiCalculator2Values) => void |
|
disabled OptionalRoiCalculator2 |
boolean |
|
state OptionalRoiCalculator2 |
'default' | 'hover' | 'active' | 'disabled' | 'error' |
|
copy OptionalRoiCalculator2 |
Partial<RoiCalculator2Copy> |
|
className OptionalRoiCalculator2 |
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-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.
scene- A wide atmosphere photo behind or beside the copy.
-
bd2c80a4229e6163.webp
image/webp · 242 KB