Two Step Opt-in 1
Two-step opt-in: a "Dear friend" letter card over an outcome photo earns the first click with one big button,
Use it in a prompt
Use forms/two-step-optin 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/forms/two-step-optin.tsx. - Import it and pass your copy and images (Props tab):
import { TwoStepOptin } from "@/components/funneldna/forms/two-step-optin"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/forms/two-step-optin/component.tsx 526 lines
// layout: photo-overlap-card
// Two-step opt-in: a "Dear friend" letter card over an outcome photo earns the first click with one big button,
// then a 50%-complete popup collects name and email and hands them to onSubmit.
import * as React from "react"
import { Check, CircleAlert, CircleCheck, LoaderCircle, Lock, X } from "lucide-react"
export type TwoStepOptinValues = { name: string; email: string }
export type TwoStepOptinErrors = {
/** Shown when the name field is empty. */
nameRequired?: string
/** Shown when the email field is empty. */
emailRequired?: string
/** Shown when the email does not look like an address. */
emailInvalid?: string
/** Shown when onSubmit rejects. */
submit?: string
}
export type TwoStepOptinProps = {
/** Letter salutation above the headline. */
salutation?: string
/** Headline. Wrap the key phrase in <span className="cf2s-mark"> for the marker stroke. */
headline?: React.ReactNode
/** Short letter paragraphs between the headline and the sign-off. */
paragraphs?: React.ReactNode[]
/** Closing line above the signer. */
signOff?: string
/** Name shown under the sign-off. */
signer?: string
/** Step-one button: action line. */
buttonLabel?: string
/** Step-one button: reassurance line. */
buttonSubLabel?: string
/** Outcome photo the card overlaps (slot "scene"). */
sceneImage?: string
sceneAlt?: string
/** Product cut-out on a transparent background (slot "product"). */
productImage?: string
productAlt?: string
/** Replaces {product} in popupLine. */
productName?: string
/** Popup progress heading; also the progress bar's accessible label. */
stepLabel?: string
/** Progress text beside the step label; also the bar's aria-valuetext. */
progressLabel?: string
/** Progress bar fill, 0 to 100. */
progress?: number
/** Step one (done) and step two (current). */
steps?: [string, string]
/** Accessible label for the steps list. */
stepsLabel?: string
popupHeadline?: string
/** One short line under the popup headline; {product} is replaced with productName. */
popupLine?: string
nameLabel?: string
namePlaceholder?: string
emailLabel?: string
emailPlaceholder?: string
/** Popup submit button: action line. */
submitLabel?: string
/** Popup submit button: reassurance line. */
submitSubLabel?: string
/** Submit button text while onSubmit's promise is pending. */
pendingLabel?: string
/** Privacy line under the submit button. */
privacy?: string
/** Quiet decline button that closes the popup. */
decline?: string
/** Accessible label for the popup's close icon button. */
closeLabel?: string
/** Validation and submit-failure messages; each falls back to the approved default. */
errors?: TwoStepOptinErrors
/** Prefilled field values. */
initialValues?: Partial<TwoStepOptinValues>
/** Receives validated values; return a promise to show the sending state. Never sends anything itself. */
onSubmit?: (values: TwoStepOptinValues) => void | Promise<void>
/** Called when the step-one button opens the popup. */
onAction?: () => void
/** Forced state for previews; "error" opens the popup with validation shown. */
state?: "default" | "hover" | "active" | "disabled" | "error"
/** Root class for page-level placement. */
className?: string
}
export function TwoStepOptin(props: TwoStepOptinProps) {
const {
salutation = "Dear friend,",
headline = DEFAULT_HEADLINE,
paragraphs = DEFAULT_PARAGRAPHS,
signOff = "To your first launch,",
signer = "The Funnel Starter team",
buttonLabel = "Yes! Send me the free guide",
buttonSubLabel = "Free guide · Takes 30 seconds",
sceneImage,
sceneAlt = "",
productImage,
productAlt = "",
productName = "guide",
stepLabel = "Step 2 of 2",
progressLabel = "50% complete",
progress = 50,
steps = ["Choose your guide", "Your details"],
stepsLabel = "Sign-up steps",
popupHeadline = "Where should we send your guide?",
popupLine = "Tell us where to send your free {product}.",
nameLabel = "Full name",
namePlaceholder = "Jane Smith",
emailLabel = "Email address",
emailPlaceholder = "you@example.com",
submitLabel = "Send me the free guide",
submitSubLabel = "100% free · Sent to your inbox",
pendingLabel = "Sending your guide…",
privacy = "We respect your inbox. Unsubscribe anytime.",
decline = "No thanks, I'll plan my funnel on my own",
closeLabel = "Close",
errors,
initialValues,
onSubmit,
onAction,
state = "default",
className,
} = props
const err = { ...DEFAULT_ERRORS, ...errors }
const pct = Math.max(0, Math.min(100, progress))
const isError = state === "error"
const baseId = React.useId()
const dialogId = `${baseId}-dialog`
const popTitleId = `${baseId}-title`
const popLineId = `${baseId}-line`
const dialogRef = React.useRef<HTMLDialogElement>(null)
const triggerRef = React.useRef<HTMLButtonElement>(null)
const nameRef = React.useRef<HTMLInputElement>(null)
const emailRef = React.useRef<HTMLInputElement>(null)
const [values, setValues] = React.useState<TwoStepOptinValues>({
name: initialValues?.name ?? "",
email: initialValues?.email ?? "",
})
const [touched, setTouched] = React.useState<Record<FieldKey, boolean>>({ name: isError, email: isError })
const [submitted, setSubmitted] = React.useState(isError)
const [pending, setPending] = React.useState(false)
const [formError, setFormError] = React.useState("")
const fieldErrors: Record<FieldKey, string> = {
name: values.name.trim() ? "" : err.nameRequired,
email: !values.email.trim()
? err.emailRequired
: EMAIL_PATTERN.test(values.email.trim())
? ""
: err.emailInvalid,
}
const visibleError = (key: FieldKey) => (submitted || touched[key] ? fieldErrors[key] : "")
const showDialog = React.useCallback(() => {
const dialog = dialogRef.current
if (!dialog || dialog.open) return
if (typeof dialog.showModal === "function") dialog.showModal()
else dialog.setAttribute("open", "")
}, [])
const closeDialog = () => {
const dialog = dialogRef.current
if (!dialog || !dialog.open) return
if (typeof dialog.close === "function") dialog.close()
else dialog.removeAttribute("open")
}
React.useEffect(() => {
if (isError) showDialog()
}, [isError, showDialog])
const handleOpen = () => {
if (state === "disabled") return
showDialog()
nameRef.current?.focus()
onAction?.()
}
const handleClose = () => {
setFormError("")
if (!isError) {
setTouched({ name: false, email: false })
setSubmitted(false)
}
triggerRef.current?.focus()
}
const handleBackdrop = (event: React.MouseEvent<HTMLDialogElement>) => {
if (event.target === event.currentTarget) closeDialog()
}
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
if (pending) return
setSubmitted(true)
setFormError("")
if (fieldErrors.name) {
nameRef.current?.focus()
return
}
if (fieldErrors.email) {
emailRef.current?.focus()
return
}
try {
setPending(true)
await onSubmit?.({ name: values.name.trim(), email: values.email.trim() })
} catch {
setFormError(err.submit)
} finally {
setPending(false)
}
}
const renderField = (key: FieldKey) => {
const isName = key === "name"
const error = visibleError(key)
const valid = !fieldErrors[key] && (submitted || touched[key])
const id = `${baseId}-${key}`
const errorId = `${id}-error`
return (
<div className="cf2s-field">
<label htmlFor={id}>{isName ? nameLabel : emailLabel}</label>
<div className="cf2s-control">
<input
ref={isName ? nameRef : emailRef}
id={id}
name={key}
type={isName ? "text" : "email"}
inputMode={isName ? undefined : "email"}
autoComplete={key}
enterKeyHint={isName ? "next" : "send"}
spellCheck={isName ? undefined : false}
placeholder={isName ? namePlaceholder : emailPlaceholder}
value={values[key]}
aria-required="true"
aria-invalid={error ? true : undefined}
aria-describedby={error ? errorId : undefined}
onChange={(event) => {
const next = event.target.value
setValues((current) => ({ ...current, [key]: next }))
if (formError) setFormError("")
}}
onBlur={() => {
if (values[key].trim()) setTouched((current) => ({ ...current, [key]: true }))
}}
/>
{valid ? <CircleCheck className="cf2s-ok" aria-hidden="true" /> : null}
</div>
{error ? (
<p className="cf2s-error" id={errorId}>
<CircleAlert aria-hidden="true" />
<span>{error}</span>
</p>
) : null}
</div>
)
}
const stageClass = ["cf2s-stage", sceneImage ? "has-photo" : "", productImage ? "has-product" : ""]
.filter(Boolean)
.join(" ")
return (
<div className={["cf-two-step-optin", className].filter(Boolean).join(" ")}>
<style>{CSS}</style>
<div className={stageClass}>
{sceneImage ? (
<figure className="cf2s-photo">
<img src={sceneImage} alt={sceneAlt} decoding="async" />
</figure>
) : null}
<div className="cf2s-card">
{productImage ? (
<img className="cf2s-product" src={productImage} alt={productAlt} width={160} height={160} />
) : null}
<p className="cf2s-salute">{salutation}</p>
<h2 className="cf2s-title">{headline}</h2>
<div className="cf2s-letter">
{paragraphs.map((paragraph, index) => (
<p key={index}>{paragraph}</p>
))}
</div>
<p className="cf2s-sign">
{signOff}
<span className="cf2s-signer">{signer}</span>
</p>
<button
ref={triggerRef}
type="button"
className="cf2s-btn cf2s-trigger"
data-force={state === "hover" || state === "active" ? state : undefined}
disabled={state === "disabled"}
aria-haspopup="dialog"
aria-controls={dialogId}
onClick={handleOpen}
>
<span className="cf2s-btn-main">{buttonLabel}</span>
<span className="cf2s-btn-sub">{buttonSubLabel}</span>
</button>
</div>
</div>
<dialog
ref={dialogRef}
id={dialogId}
className="cf2s-dialog"
aria-labelledby={popTitleId}
aria-describedby={popLineId}
onClick={handleBackdrop}
onClose={handleClose}
>
<div className="cf2s-sheet">
<button type="button" className="cf2s-close" aria-label={closeLabel} onClick={closeDialog}>
<X aria-hidden="true" />
</button>
<div className="cf2s-prog-head">
<span className="cf2s-step">{stepLabel}</span>
<span className="cf2s-pct">{progressLabel}</span>
</div>
<div
className="cf2s-track"
role="progressbar"
aria-label={stepLabel}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={pct}
aria-valuetext={progressLabel}
style={{ "--cf2s-p": `${pct}%` } as React.CSSProperties}
>
<span className="cf2s-fill" />
</div>
<ol className="cf2s-steps" aria-label={stepsLabel}>
<li className="is-done">
<Check aria-hidden="true" />
{steps[0]}
</li>
<li className="is-current" aria-current="step">
{steps[1]}
</li>
</ol>
<div className="cf2s-offer">
{productImage ? (
<img className="cf2s-thumb" src={productImage} alt={productAlt} width={96} height={96} />
) : null}
<div className="cf2s-offer-copy">
<h2 className="cf2s-pop-title" id={popTitleId}>
{popupHeadline}
</h2>
<p className="cf2s-pop-line" id={popLineId}>
{fillProduct(popupLine, productName)}
</p>
</div>
</div>
<form className="cf2s-form" noValidate onSubmit={handleSubmit} aria-busy={pending || undefined}>
{renderField("name")}
{renderField("email")}
{formError ? (
<p className="cf2s-form-error" role="alert">
<CircleAlert aria-hidden="true" />
<span>{formError}</span>
</p>
) : null}
<button
type="submit"
className={pending ? "cf2s-btn cf2s-submit is-pending" : "cf2s-btn cf2s-submit"}
aria-disabled={pending || undefined}
>
{pending ? (
<span className="cf2s-btn-main cf2s-pending">
<LoaderCircle className="cf2s-spin" aria-hidden="true" />
{pendingLabel}
</span>
) : (
<>
<span className="cf2s-btn-main">{submitLabel}</span>
<span className="cf2s-btn-sub">{submitSubLabel}</span>
</>
)}
</button>
<p className="cf2s-privacy">
<Lock aria-hidden="true" />
<span>{privacy}</span>
</p>
</form>
<button type="button" className="cf2s-decline" onClick={closeDialog}>
{decline}
</button>
</div>
</dialog>
</div>
)
}
export default TwoStepOptin
type FieldKey = keyof TwoStepOptinValues
const DEFAULT_HEADLINE = (
<>
Build your first funnel with a <span className="cf2s-mark">clear plan</span>
</>
)
const DEFAULT_PARAGRAPHS: React.ReactNode[] = [
"You don't need more tools to launch. You need to know which pages your funnel needs, and what goes on each one.",
"This free guide maps it out for you, page by page. Tell us where to send it.",
]
const DEFAULT_ERRORS: Required<TwoStepOptinErrors> = {
nameRequired: "Please enter your name so we know who it's for.",
emailRequired: "Please enter your email so we can send your guide.",
emailInvalid: "That email doesn't look right. Check it and try again.",
submit: "We couldn't send that just now. Please try again.",
}
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/
function fillProduct(template: string, product: string) {
return template.split("{product}").join(product)
}
const CSS = `
.cf-two-step-optin{--cf2s-radius:var(--card-radius,var(--radius,14px));--cf2s-marker:var(--marker,#fae37c);--cf2s-shadow:var(--shadow,oklch(0.22 0.03 256));container-type:inline-size;position:relative;width:100%;max-width:68rem;margin-inline:auto;color:var(--ink);font-family:var(--font-body)}
.cf-two-step-optin *,.cf-two-step-optin *::before,.cf-two-step-optin *::after{box-sizing:border-box}
.cf-two-step-optin .cf2s-stage{display:grid;grid-template-columns:minmax(0,1fr)}
.cf-two-step-optin .cf2s-stage.has-product:not(.has-photo){padding-top:4.75rem}
.cf-two-step-optin .cf2s-photo{position:relative;margin:0;aspect-ratio:4/3;overflow:hidden;border-radius:var(--cf2s-radius);background:color-mix(in oklch,var(--ink) 6%,var(--card));box-shadow:var(--shadow-md,0 1px 2px oklch(from var(--cf2s-shadow) l c h / .22),0 4px 10px -2px oklch(from var(--cf2s-shadow) l c h / .2))}
.cf-two-step-optin .cf2s-photo img{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:cover;object-position:35% 40%}
.cf-two-step-optin .cf2s-photo::after{content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,transparent 50%,oklch(from var(--band) l c h / .35))}
.cf-two-step-optin .cf2s-card{position:relative;z-index:1;margin:0;padding:clamp(1.5rem,5cqi,2.75rem) clamp(1.25rem,4.5cqi,2.75rem) clamp(1.5rem,4.5cqi,2.5rem);background:var(--card);color:var(--ink);border:1px solid var(--card-border,color-mix(in oklch,var(--ink) 12%,transparent));border-radius:var(--cf2s-radius);box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px oklch(from var(--cf2s-shadow) l c h / .22),0 12px 24px -8px oklch(from var(--cf2s-shadow) l c h / .32)))}
.cf-two-step-optin .has-photo .cf2s-card{margin:-4.5rem clamp(.5rem,3cqi,1rem) 0}
.cf-two-step-optin .cf2s-product{position:absolute;top:-4.25rem;right:clamp(.75rem,3cqi,1.75rem);width:6.5rem;height:6.5rem;object-fit:contain;rotate:6deg;pointer-events:none;filter:drop-shadow(0 2px 2px oklch(from var(--cf2s-shadow) l c h / .3)) drop-shadow(0 8px 10px oklch(from var(--cf2s-shadow) l c h / .22))}
.cf-two-step-optin .cf2s-salute{margin:0 0 .875rem;padding-right:6.5rem;font-size:1.1875rem;font-weight:700;line-height:1.35;color:var(--ink)}
.cf-two-step-optin .cf2s-title{margin:0 0 clamp(.875rem,1.6cqi,1.125rem);font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,-.025em);font-size:clamp(2rem,4.3cqi,2.875rem);line-height:1.04;text-wrap:balance;color:var(--ink)}
.cf-two-step-optin .cf2s-mark{color:inherit;background-color:transparent;background-image:linear-gradient(var(--cf2s-marker),var(--cf2s-marker));background-repeat:no-repeat;background-size:100% .56em;background-position:0 88%;padding-inline:.12em;margin-inline:-.12em;border-radius:.3em .55em .35em .5em / .6em .4em .5em .45em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-two-step-optin .cf2s-letter p{margin:0 0 .875rem;max-width:60ch;font-size:clamp(1.0625rem,1.6cqi,1.1875rem);font-weight:400;line-height:1.55;text-wrap:pretty;color:var(--ink)}
.cf-two-step-optin .cf2s-sign{margin:1.125rem 0 1.5rem;font-size:1.0625rem;line-height:1.4;color:var(--muted)}
.cf-two-step-optin .cf2s-signer{display:block;margin-top:.2rem;font-family:var(--font-display);font-size:1.1875rem;font-weight:800;color:var(--ink)}
.cf-two-step-optin .cf2s-btn{--cf2s-b:var(--button-bg,var(--cta));--cf2s-b2:var(--button-bg-2,var(--cta-2));appearance:none;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.3rem;width:100%;min-height:4.25rem;margin:0;padding:.95rem 1rem 1.05rem;border:1px solid oklch(from var(--cf2s-b2) calc(l - .08) c h);border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(oklch(from var(--cf2s-b) calc(l + .04) c h),var(--cf2s-b2));color:var(--button-ink,var(--cta-ink));font-family:var(--button-font,var(--font-display));text-transform:var(--button-case,none);text-align:center;text-shadow:var(--button-text-shadow,none);cursor:pointer;box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--cf2s-b) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--cf2s-b2) calc(l - .12) c h),0 1px 2px oklch(from var(--cf2s-shadow) l c h / .35),0 8px 16px -6px oklch(from var(--cf2s-shadow) l c h / .45))}
.cf-two-step-optin .cf2s-btn:hover:not(:disabled),.cf-two-step-optin .cf2s-btn[data-force="hover"]{background:linear-gradient(oklch(from var(--cf2s-b) calc(l + .08) c h),oklch(from var(--cf2s-b2) calc(l + .02) c h));transform:translateY(-2px);box-shadow:inset 0 1px 0 oklch(from var(--cf2s-b) calc(l + .16) c h / .75),inset 0 -3px 0 oklch(from var(--cf2s-b2) calc(l - .12) c h),0 2px 3px oklch(from var(--cf2s-shadow) l c h / .35),0 12px 20px -8px oklch(from var(--cf2s-shadow) l c h / .5)}
.cf-two-step-optin .cf2s-btn:active:not(:disabled),.cf-two-step-optin .cf2s-btn[data-force="active"]{background:linear-gradient(var(--cf2s-b2),oklch(from var(--cf2s-b2) calc(l - .04) c h));transform:translateY(1px);box-shadow:inset 0 2px 3px oklch(from var(--cf2s-b2) calc(l - .18) c h / .6),0 1px 1px oklch(from var(--cf2s-shadow) l c h / .3)}
.cf-two-step-optin .cf2s-btn:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-two-step-optin .cf2s-btn:disabled{background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));border-color:transparent;text-shadow:none;box-shadow:none;cursor:not-allowed;transform:none}
.cf-two-step-optin .cf2s-btn.is-pending{cursor:progress;transform:none}
.cf-two-step-optin .cf2s-btn-main{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;font-size:clamp(1.125rem,2.3cqi,1.5rem);font-weight:var(--button-weight,800);line-height:1.12;text-wrap:balance}
.cf-two-step-optin .cf2s-btn-sub{font-family:var(--font-body);font-size:.9375rem;font-weight:400;line-height:1.3;text-wrap:pretty}
.cf-two-step-optin .cf2s-spin{width:1.15em;height:1.15em;flex:none}
.cf-two-step-optin .cf2s-dialog{width:min(34rem,calc(100vw - 1.5rem));max-width:none;max-height:calc(100dvh - 1.5rem);margin:auto;padding:0;overflow:auto;overscroll-behavior:contain;border:1px solid var(--card-border,color-mix(in oklch,var(--ink) 12%,transparent));border-radius:calc(var(--cf2s-radius) + 4px);background:var(--card);color:var(--ink);font-family:var(--font-body);box-shadow:0 2px 4px oklch(from var(--cf2s-shadow) l c h / .25),0 24px 48px -16px oklch(from var(--cf2s-shadow) l c h / .5)}
.cf-two-step-optin .cf2s-dialog::backdrop{background:oklch(from var(--band,oklch(0.27 0.07 256)) calc(l - .05) c h / .66);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
.cf-two-step-optin .cf2s-sheet{position:relative;padding:1.5rem clamp(1.125rem,5vw,2.25rem) clamp(1.25rem,4vw,1.75rem)}
.cf-two-step-optin .cf2s-close{--cf2s-close-bg:var(--button-2-bg,color-mix(in oklch,var(--ink) 6%,var(--card)));position:absolute;top:.625rem;right:.625rem;display:grid;width:2.75rem;height:2.75rem;place-items:center;padding:0;border:0;border-radius:999px;background:var(--cf2s-close-bg);color:var(--button-2-ink,var(--ink));cursor:pointer}
.cf-two-step-optin .cf2s-close:hover{background:color-mix(in oklch,var(--button-2-ink,var(--ink)) 12%,var(--card))}
.cf-two-step-optin .cf2s-close:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:2px}
.cf-two-step-optin .cf2s-close svg{width:1.25rem;height:1.25rem;stroke-width:2.5}
.cf-two-step-optin .cf2s-prog-head{display:flex;align-items:baseline;justify-content:space-between;gap:1rem;margin:0 3.25rem .75rem 0}
.cf-two-step-optin .cf2s-step{font-family:var(--font-display);font-size:1.1875rem;font-weight:800;line-height:1.2;color:var(--ink)}
.cf-two-step-optin .cf2s-pct{font-size:1rem;font-weight:700;line-height:1.2;color:var(--accent);white-space:nowrap}
.cf-two-step-optin .cf2s-track{position:relative;height:.875rem;overflow:hidden;border-radius:999px;background:color-mix(in oklch,var(--ink) 9%,var(--card));box-shadow:inset 0 1px 2px oklch(from var(--cf2s-shadow) l c h / .18)}
.cf-two-step-optin .cf2s-fill{position:relative;display:block;width:var(--cf2s-p,50%);height:100%;overflow:hidden;border-radius:inherit;background:linear-gradient(oklch(from var(--accent-fill,var(--accent)) calc(l + .07) c h),oklch(from var(--accent-fill,var(--accent)) calc(l - .03) c h));box-shadow:inset 0 -2px 0 oklch(from var(--accent-fill,var(--accent)) calc(l - .1) c h / .5)}
.cf-two-step-optin .cf2s-fill::before{content:"";position:absolute;inset:0 0 0 -2rem;background:repeating-linear-gradient(-45deg,oklch(from var(--accent-fill,var(--accent)) calc(l + .14) c h / .45) 0 .5rem,transparent .5rem 1rem)}
.cf-two-step-optin .cf2s-steps{display:flex;justify-content:space-between;gap:.75rem;margin:.75rem 0 0;padding:0;list-style:none;font-size:.9375rem;line-height:1.3}
.cf-two-step-optin .cf2s-steps li{display:inline-flex;align-items:center;gap:.35rem}
.cf-two-step-optin .cf2s-steps .is-done{color:var(--muted)}
.cf-two-step-optin .cf2s-steps .is-done svg{width:1.1em;height:1.1em;flex:none;color:var(--success);stroke-width:3}
.cf-two-step-optin .cf2s-steps .is-current{font-weight:700;color:var(--ink);text-align:right}
.cf-two-step-optin .cf2s-offer{display:flex;align-items:flex-start;gap:1rem;margin:1.5rem 0 1.375rem}
.cf-two-step-optin .cf2s-thumb{flex:none;width:clamp(4.25rem,18vw,5.5rem);height:auto;aspect-ratio:1;object-fit:contain;rotate:-5deg;filter:drop-shadow(0 2px 2px oklch(from var(--cf2s-shadow) l c h / .3)) drop-shadow(0 6px 8px oklch(from var(--cf2s-shadow) l c h / .2))}
.cf-two-step-optin .cf2s-offer-copy{min-width:0}
.cf-two-step-optin .cf2s-pop-title{margin:0 0 .5rem;font-family:var(--font-display);font-weight:var(--display-weight,800);text-transform:var(--display-case,none);letter-spacing:var(--display-tracking,-.02em);font-size:clamp(1.5rem,4.6vw,1.875rem);line-height:1.1;text-wrap:balance;color:var(--ink)}
.cf-two-step-optin .cf2s-pop-line{margin:0;font-size:1.0625rem;line-height:1.45;text-wrap:pretty;color:var(--muted)}
.cf-two-step-optin .cf2s-form{display:grid;margin:0}
.cf-two-step-optin .cf2s-field{display:grid;gap:.45rem;margin-bottom:1rem}
.cf-two-step-optin .cf2s-field label{font-size:1.0625rem;font-weight:700;line-height:1.25;color:var(--label-ink,var(--ink))}
.cf-two-step-optin .cf2s-control{position:relative}
.cf-two-step-optin .cf2s-control input{display:block;width:100%;min-height:3.5rem;margin:0;padding:.8rem 2.85rem .8rem 1rem;border:1.5px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,10px));background:var(--field);color:var(--field-ink);font:inherit;font-family:var(--font-body);font-size:1.0625rem;line-height:1.3;box-shadow:inset 0 1px 2px oklch(from var(--cf2s-shadow) l c h / .08);outline:none}
.cf-two-step-optin .cf2s-control input::placeholder{color:color-mix(in oklch,var(--field-ink) 65%,var(--field));opacity:1}
.cf-two-step-optin .cf2s-control input:hover{border-color:color-mix(in oklch,var(--ink) 40%,transparent)}
.cf-two-step-optin .cf2s-control input:focus-visible{border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 4px oklch(from var(--field-focus,var(--accent)) l c h / .22)}
.cf-two-step-optin .cf2s-control input[aria-invalid="true"]{border-color:var(--danger)}
.cf-two-step-optin .cf2s-control input[aria-invalid="true"]:focus-visible{box-shadow:0 0 0 4px oklch(from var(--danger) l c h / .18)}
.cf-two-step-optin .cf2s-ok{position:absolute;top:50%;right:1rem;width:1.25rem;height:1.25rem;translate:0 -50%;color:var(--success);pointer-events:none}
.cf-two-step-optin .cf2s-error{display:flex;align-items:flex-start;gap:.4rem;margin:0;font-size:.9375rem;font-weight:700;line-height:1.35;color:var(--danger);text-wrap:pretty}
.cf-two-step-optin .cf2s-error svg{width:1.1em;height:1.1em;flex:none;margin-top:.12em}
.cf-two-step-optin .cf2s-form-error{display:flex;align-items:flex-start;gap:.5rem;margin:0 0 1rem;padding:.75rem .9rem;border-radius:var(--field-radius,var(--radius,10px));background:var(--danger-soft);color:var(--danger);font-size:.9375rem;font-weight:700;line-height:1.35}
.cf-two-step-optin .cf2s-form-error svg{width:1.1em;height:1.1em;flex:none;margin-top:.12em}
.cf-two-step-optin .cf2s-submit{margin-top:.5rem}
.cf-two-step-optin .cf2s-privacy{display:flex;align-items:center;justify-content:center;gap:.4rem;margin:.875rem 0 0;font-size:.875rem;line-height:1.35;color:var(--muted);text-align:center;text-wrap:pretty}
.cf-two-step-optin .cf2s-privacy svg{width:1em;height:1em;flex:none}
.cf-two-step-optin .cf2s-decline{display:block;min-height:2.75rem;margin:.625rem auto 0;padding:.5rem .75rem;border:0;border-radius:var(--button-radius,6px);background:none;color:var(--muted);font-family:var(--font-body);font-size:.9375rem;line-height:1.35;text-align:center;text-decoration:underline;text-decoration-color:oklch(from var(--muted) l c h / .45);text-underline-offset:.18em;cursor:pointer}
.cf-two-step-optin .cf2s-decline:hover{color:var(--ink);text-decoration-color:currentColor}
.cf-two-step-optin .cf2s-decline:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:2px}
@container (min-width:760px){
.cf-two-step-optin .cf2s-stage{grid-template-columns:repeat(12,minmax(0,1fr))}
.cf-two-step-optin .cf2s-stage.has-photo.has-product{padding-top:1.25rem}
.cf-two-step-optin .cf2s-photo{grid-column:1/9;grid-row:1;aspect-ratio:auto;min-height:26rem}
.cf-two-step-optin .cf2s-photo::after{background:linear-gradient(90deg,transparent 45%,oklch(from var(--band) l c h / .35))}
.cf-two-step-optin .cf2s-card{grid-column:3/11}
.cf-two-step-optin .has-photo .cf2s-card{grid-column:7/13;grid-row:1;align-self:center;margin:clamp(3rem,7cqi,5rem) 0}
.cf-two-step-optin .cf2s-product{top:-4.5rem;width:8.75rem;height:8.75rem}
.cf-two-step-optin .cf2s-salute{padding-right:8.5rem}
}
@keyframes cf2s-settle{from{transform:scale(1.06)}to{transform:scale(1)}}
@keyframes cf2s-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cf2s-drop{from{opacity:0;transform:translateY(-14px)}to{opacity:1;transform:none}}
@keyframes cf2s-mark{from{background-size:0 .56em}}
@keyframes cf2s-pop{from{opacity:0;transform:translateY(12px) scale(.97)}to{opacity:1;transform:none}}
@keyframes cf2s-fade{from{opacity:0}to{opacity:1}}
@keyframes cf2s-stripes{to{transform:translateX(1.4142rem)}}
@keyframes cf2s-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:no-preference){
.cf-two-step-optin .cf2s-photo img{animation:cf2s-settle 1.4s cubic-bezier(.2,.7,.2,1) both}
.cf-two-step-optin .cf2s-card{animation:cf2s-rise .5s cubic-bezier(.2,.7,.2,1) both}
.cf-two-step-optin .cf2s-product{animation:cf2s-drop .7s .15s cubic-bezier(.2,.8,.25,1.15) both}
.cf-two-step-optin .cf2s-mark{animation:cf2s-mark .8s .35s cubic-bezier(.3,.7,.2,1) both}
.cf-two-step-optin .cf2s-btn{transition:transform .15s ease,box-shadow .15s ease,background .15s ease}
.cf-two-step-optin .cf2s-control input{transition:border-color .15s ease,box-shadow .15s ease}
.cf-two-step-optin .cf2s-dialog[open]{animation:cf2s-pop .28s cubic-bezier(.2,.8,.2,1)}
.cf-two-step-optin .cf2s-dialog[open]::backdrop{animation:cf2s-fade .28s ease}
.cf-two-step-optin .cf2s-fill::before{animation:cf2s-stripes 1s linear 5}
.cf-two-step-optin .cf2s-spin{animation:cf2s-spin .9s linear infinite}
}
`
pieces/forms/two-step-optin/specimen.tsx 28 lines
import sceneArt from "../assets/2a51f442a42552b2.webp"
import productArt from "../assets/4ba8f3e6a559c9f5.webp"
import { TwoStepOptin, type TwoStepOptinProps } from "../two-step-optin"
import defaults from "../../studio-defaults.json"
import { slot } from "../../slots"
export const states = ["default", "hover", "active", "disabled", "error"]
export default function TwoStepOptinSpecimen({ state = "default" }: { state?: TwoStepOptinProps["state"] }) {
const sample = defaults.sample
const guide = sample.items[0]
return (
<TwoStepOptin
state={state}
paragraphs={[
"You don't need more tools to launch. You need to know which pages your funnel needs, and what goes on each one.",
`The free ${guide.name} maps it out for you, page by page. Tell us where to send it.`,
]}
sceneImage={slot("scene", sceneArt)}
sceneAlt="A woman mapping out her funnel plan with sticky notes on a wall board"
productImage={slot("product", productArt)}
productAlt={guide.imageAlt}
productName={guide.name}
privacy={sample.registration.privacy}
initialValues={state === "error" ? { name: "", email: "jane@example" } : undefined}
/>
)
}
| Name | Type | Details |
|---|---|---|
salutation OptionalTwoStepOptin |
string |
|
headline OptionalTwoStepOptin |
React.ReactNode |
|
paragraphs OptionalTwoStepOptin |
React.ReactNode[] |
|
signOff OptionalTwoStepOptin |
string |
|
signer OptionalTwoStepOptin |
string |
|
buttonLabel OptionalTwoStepOptin |
string |
|
buttonSubLabel OptionalTwoStepOptin |
string |
|
sceneImage OptionalTwoStepOptin |
string |
|
sceneAlt OptionalTwoStepOptin |
string |
|
productImage OptionalTwoStepOptin |
string |
|
productAlt OptionalTwoStepOptin |
string |
|
productName OptionalTwoStepOptin |
string |
|
stepLabel OptionalTwoStepOptin |
string |
|
progressLabel OptionalTwoStepOptin |
string |
|
progress OptionalTwoStepOptin |
number |
|
steps OptionalTwoStepOptin |
[string, string] |
|
stepsLabel OptionalTwoStepOptin |
string |
|
popupHeadline OptionalTwoStepOptin |
string |
|
popupLine OptionalTwoStepOptin |
string |
|
nameLabel OptionalTwoStepOptin |
string |
|
namePlaceholder OptionalTwoStepOptin |
string |
|
emailLabel OptionalTwoStepOptin |
string |
|
emailPlaceholder OptionalTwoStepOptin |
string |
|
submitLabel OptionalTwoStepOptin |
string |
|
submitSubLabel OptionalTwoStepOptin |
string |
|
pendingLabel OptionalTwoStepOptin |
string |
|
privacy OptionalTwoStepOptin |
string |
|
decline OptionalTwoStepOptin |
string |
|
closeLabel OptionalTwoStepOptin |
string |
|
errors OptionalTwoStepOptin |
TwoStepOptinErrors |
|
initialValues OptionalTwoStepOptin |
Partial<TwoStepOptinValues> |
|
onSubmit OptionalTwoStepOptin |
(values: TwoStepOptinValues) => void | Promise<void> |
|
onAction OptionalTwoStepOptin |
() => void |
|
state OptionalTwoStepOptin |
"default" | "hover" | "active" | "disabled" | "error" |
|
className OptionalTwoStepOptin |
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- 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.
-
2a51f442a42552b2.webp
image/webp · 59.1 KB
-
4ba8f3e6a559c9f5.webp
image/webp · 79.9 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB