Squeeze Opt-in 1
Two-step lead capture: a CTA button that opens the email form in a dialog.
Use it in a prompt
Use hero/squeeze-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/hero/squeeze-optin.tsx. - Import it and pass your copy and images (Props tab):
import { SqueezeOptin } from "@/components/funneldna/hero/squeeze-optin"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/hero/squeeze-optin/component.tsx 513 lines
// Opens a two-step registration dialog from an envelope invitation: hook, invite, one big button, then the short form.
"use client"
import * as React from "react"
import { AlertCircle, Check, Loader2, Lock, MonitorPlay, X } from "lucide-react"
export type SqueezeOptinProps = {
/** Supporting labels and plain-text templates; named placeholders are documented on SqueezeOptinCopy. */
copy?: Partial<SqueezeOptinCopy>
/** Short pre-headline above the headline. */
preheadline?: string
headline: string
/** Phrase inside the headline that gets the marker stroke. */
highlight?: string
lead?: string
/** Slot "product": the opened envelope / mailer cut-out. productImage is canonical; image is kept for older callers. */
productImage?: string
image?: string
imageAlt?: string
/** Up to three short "what's inside" tags around the envelope. */
insideLabels?: (string | { label: string })[]
/** Accessible name for the tag list. */
insideTitle?: string
ctaLabel?: string
/** One short reassurance line under the button. */
ctaSublabel?: string
formTitle?: string
formSubtitle?: string
progressLabel?: string
stepLabels?: [string, string]
fields?: SqueezeOptinField[]
submitLabel?: string
privacyNote?: string
/** @deprecated No longer rendered: the builder wires what happens after a valid submit. */
successMessage?: React.ReactNode
/** @deprecated No longer rendered. */
completeLabel?: string
errorMessage?: string
onSubmit?: (values: Record<string, string>) => void | Promise<void>
/** "success" is accepted for older callers and renders as default. */
state?: SqueezeOptinState
className?: string
}
export function SqueezeOptin({
preheadline,
headline,
highlight,
lead,
image: legacyImage,
productImage: image = legacyImage,
imageAlt = "",
insideLabels: suppliedLabels = [],
insideTitle = "Inside the workshop",
ctaLabel = "Yes! Save My Seat",
ctaSublabel,
formTitle = "Save your seat",
formSubtitle,
progressLabel = "You’re almost in",
stepLabels = ["Seat chosen", "Your details"],
fields = DEFAULT_FIELDS,
submitLabel,
privacyNote = "We respect your inbox. Unsubscribe anytime.",
errorMessage = "We couldn’t complete your registration. Please try again.",
onSubmit,
state = "default",
className,
copy,
}: SqueezeOptinProps) {
const text = { ...DEFAULT_COPY, ...copy }
const insideLabels = suppliedLabels.map((item) => (typeof item === "string" ? item : item.label))
const uid = React.useId()
const emailField = fields.find((f) => f.type === "email") ?? fields[fields.length - 1]
const forcedErrors = React.useCallback(
(): Record<string, string> => (emailField ? { [emailField.name]: text.emailInvalid } : {}),
[emailField, text.emailInvalid]
)
const [open, setOpen] = React.useState(state === "error")
const [phase, setPhase] = React.useState<"idle" | "pending">("idle")
const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>(() =>
state === "error" ? forcedErrors() : {}
)
const [formError, setFormError] = React.useState<string | null>(null)
const dialogRef = React.useRef<HTMLDialogElement>(null)
const formRef = React.useRef<HTMLFormElement>(null)
const mounted = React.useRef(true)
React.useEffect(() => {
setOpen(state === "error")
setPhase("idle")
setFieldErrors(state === "error" ? forcedErrors() : {})
setFormError(null)
}, [state, forcedErrors])
React.useEffect(() => {
mounted.current = true
return () => {
mounted.current = false
}
}, [])
React.useEffect(() => {
const d = dialogRef.current
if (!d) return
if (open && !d.open) {
try {
d.showModal()
} catch {
d.setAttribute("open", "")
}
const frame = requestAnimationFrame(() => {
const target =
formRef.current?.querySelector<HTMLInputElement>("input[aria-invalid='true']") ??
formRef.current?.querySelector<HTMLInputElement>("input")
target?.focus()
})
return () => cancelAnimationFrame(frame)
} else if (!open && d.open) {
d.close()
}
}, [open])
const pending = phase === "pending"
const busy = phase !== "idle"
const pct = 50
function openForm() {
setFormError(null)
setFieldErrors({})
setOpen(true)
}
function clearError(name: string) {
setFieldErrors((prev) => {
if (!prev[name]) return prev
const next = { ...prev }
delete next[name]
return next
})
}
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault()
if (busy) return
const data = new FormData(e.currentTarget)
const values: Record<string, string> = {}
const errs: Record<string, string> = {}
for (const f of fields) {
const v = String(data.get(f.name) ?? "").trim()
values[f.name] = v
const isEmail = f.type === "email"
if (!v) errs[f.name] = isEmail ? text.emailRequired : copyText(text.required, { label: f.label.toLowerCase() })
else if (isEmail && !EMAIL_RE.test(v)) errs[f.name] = text.emailInvalid
}
setFieldErrors(errs)
setFormError(null)
const firstBad = fields.find((f) => errs[f.name])
if (firstBad) {
formRef.current?.querySelector<HTMLInputElement>(`[name="${firstBad.name}"]`)?.focus()
return
}
if (!onSubmit) return
setPhase("pending")
try {
await onSubmit(values)
if (mounted.current) setPhase("idle")
} catch {
if (!mounted.current) return
setPhase("idle")
setFormError(errorMessage)
}
}
const hasStage = !!image || insideLabels.length > 0
return (
<div className={cx("cf-squeeze-optin", className)} data-state={state}>
<style>{CSS}</style>
{preheadline && (
<p className="sqo-pre">
<MonitorPlay aria-hidden="true" strokeWidth={2.5} />
{preheadline}
</p>
)}
<h1 className="sqo-h">{withHighlight(headline, highlight)}</h1>
{lead && <p className="sqo-lead">{lead}</p>}
{hasStage && (
<div className={cx("sqo-stage", image && "has-image")}>
{image && (
<div className="sqo-env-wrap">
<img className="sqo-env" src={image} alt={imageAlt} width={1536} height={1024} decoding="async" />
</div>
)}
{insideLabels.length > 0 && (
<ul className="sqo-tags" aria-label={insideTitle}>
{insideLabels.slice(0, 3).map((label) => (
<li key={label} className="sqo-tag">
<span className="sqo-tag-ico" aria-hidden="true">
<Check strokeWidth={3} />
</span>
<span>{label}</span>
</li>
))}
</ul>
)}
</div>
)}
<div className="sqo-action">
<button
type="button"
className={cx("sqo-cta", state === "hover" && "is-hover", state === "active" && "is-active")}
disabled={state === "disabled"}
aria-haspopup="dialog"
onClick={openForm}
>
<span>{ctaLabel}</span>
</button>
{ctaSublabel && <p className="sqo-sub">{ctaSublabel}</p>}
</div>
<dialog
ref={dialogRef}
className="sqo-dialog"
aria-labelledby={`${uid}-title`}
aria-describedby={formSubtitle ? `${uid}-desc` : undefined}
onClose={() => setOpen(false)}
onCancel={(e) => {
if (busy) e.preventDefault()
}}
onClick={(e) => {
if (e.target === e.currentTarget && !busy) setOpen(false)
}}
>
<div>
<div className="sqo-head">
<div className="sqo-head-row">
<div className="sqo-prog">
<div className="sqo-prog-row">
<span className="sqo-prog-label">{progressLabel}</span>
<span className="sqo-prog-pct">{copyText(text.percent, { percent: pct })}</span>
</div>
<div
className="sqo-track"
role="progressbar"
aria-label={text.progressAria}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={pct}
>
<span className="sqo-fill" style={{ width: `${pct}%` }} />
</div>
</div>
<button type="button" className="sqo-close" aria-label={text.close} disabled={busy} onClick={() => setOpen(false)}>
<X strokeWidth={2.5} aria-hidden="true" />
</button>
</div>
<ol className="sqo-steps" aria-label={text.stepsAria}>
<li className="sqo-step is-done">
<span className="sqo-step-num" aria-hidden="true">
<Check strokeWidth={3} />
</span>
<span>{stepLabels[0]}</span>
</li>
<li className="sqo-step is-current" aria-current="step">
<span className="sqo-step-num" aria-hidden="true">2</span>
<span>{stepLabels[1]}</span>
</li>
</ol>
</div>
<div className="sqo-body">
<h2 id={`${uid}-title`} className="sqo-dt">
{formTitle}
</h2>
{formSubtitle && (
<p id={`${uid}-desc`} className="sqo-dd">
{formSubtitle}
</p>
)}
{formError && (
<div className="sqo-formerr" role="alert">
<AlertCircle aria-hidden="true" strokeWidth={2.5} />
<span>{formError}</span>
</div>
)}
<form ref={formRef} className="sqo-form" noValidate onSubmit={handleSubmit}>
{fields.map((f) => {
const id = `${uid}-${f.name}`
const err = fieldErrors[f.name]
return (
<div className="sqo-field" key={f.name}>
<label htmlFor={id}>{f.label}</label>
<input
id={id}
name={f.name}
type={f.type ?? "text"}
inputMode={f.type === "email" ? "email" : undefined}
autoComplete={f.autoComplete}
placeholder={placeholderFor(f, text)}
required
disabled={busy}
aria-invalid={err ? true : undefined}
aria-describedby={err ? `${id}-err` : undefined}
onInput={() => clearError(f.name)}
/>
{err && (
<p id={`${id}-err`} className="sqo-ferr">
<AlertCircle aria-hidden="true" strokeWidth={2.5} />
<span>{err}</span>
</p>
)}
</div>
)
})}
<button type="submit" className="sqo-cta is-form" disabled={busy} aria-busy={pending || undefined} data-phase={phase}>
{pending ? (
<>
<Loader2 className="sqo-spin" strokeWidth={2.5} aria-hidden="true" />
<span>{text.saving}</span>
</>
) : (
<span>{submitLabel ?? ctaLabel}</span>
)}
</button>
{privacyNote && (
<p className="sqo-privacy">
<Lock aria-hidden="true" strokeWidth={2.5} />
{privacyNote}
</p>
)}
</form>
</div>
</div>
</dialog>
</div>
)
}
export default SqueezeOptin
export type SqueezeOptinField = {
name: string
label: string
type?: string
autoComplete?: string
placeholder?: string
}
export type SqueezeOptinState = "default" | "hover" | "active" | "disabled" | "error" | "success"
const DEFAULT_FIELDS: SqueezeOptinField[] = [
{ name: "name", label: "Full name", autoComplete: "name" },
{ name: "email", label: "Email address", type: "email", autoComplete: "email" },
]
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/
function cx(...c: Array<string | false | null | undefined>) {
return c.filter(Boolean).join(" ")
}
function placeholderFor(f: SqueezeOptinField, text: SqueezeOptinCopy) {
if (f.placeholder) return f.placeholder
if (f.type === "email" || f.name === "email") return text.emailPlaceholder
if (f.name === "name") return text.namePlaceholder
return copyText(text.placeholder, { label: f.label.toLowerCase() })
}
function withHighlight(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text
const i = text.indexOf(phrase)
if (i < 0) return text
return (
<>
{text.slice(0, i)}
<span className="sqo-mark">{phrase}</span>
{text.slice(i + phrase.length)}
</>
)
}
// Every colour, face, radius and shadow reads the theme tokens; the product cut-out is a slot image with a CSS drop-shadow.
// --sqo-badge-glyph: the white glyph on solid status badges (theme-contract: solid badge, white glyph); scoped variable with a hex fallback.
const CSS = `
.cf-squeeze-optin{--sqo-btn:var(--button-bg,var(--cta,#d92d20));--sqo-btn-2:var(--button-bg-2,var(--cta-2,oklch(from var(--sqo-btn) calc(l - 0.07) c h)));--sqo-sh:var(--shadow,oklch(0.22 0.03 256));--sqo-badge-glyph:var(--status-glyph,#fff);position:relative;width:100%;max-width:48rem;margin-inline:auto;text-align:center;color:var(--ink,#101828);font-family:var(--font-body,Arial,sans-serif);-webkit-font-smoothing:antialiased}
.cf-squeeze-optin *,.cf-squeeze-optin *::before,.cf-squeeze-optin *::after{box-sizing:border-box}
:where(.cf-squeeze-optin) .sqo-pre{margin:0 0 1rem;color:var(--accent,#0f5fc2);font-family:var(--font-display,Arial,sans-serif);font-weight:800;font-size:clamp(1rem,1.3vw,1.125rem);line-height:1.3;text-wrap:balance}
:where(.cf-squeeze-optin) .sqo-pre svg{display:inline-block;width:1.25em;height:1.25em;margin-inline-end:.4em;vertical-align:-.25em}
:where(.cf-squeeze-optin) .sqo-h{margin:0;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,800);font-size:clamp(2.5rem,5.4vw,4.875rem);line-height:1.04;letter-spacing:var(--display-tracking,-.025em);color:var(--ink,#101828);text-transform:var(--display-case,none);text-wrap:balance}
:where(.cf-squeeze-optin) .sqo-mark{padding:0 .1em;margin:0 -.02em;border-radius:.1em .3em .4em .18em;background-image:linear-gradient(178deg,transparent 0 46%,var(--marker,#fae37c) 46% 92%,transparent 92%);-webkit-box-decoration-break:clone;box-decoration-break:clone}
:where(.cf-squeeze-optin) .sqo-lead{margin:clamp(1rem,1.8vw,1.5rem) auto 0;max-width:36rem;color:var(--muted,#4a5565);font-weight:500;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.45;text-wrap:pretty}
:where(.cf-squeeze-optin) .sqo-stage{position:relative;max-width:40rem;margin:clamp(1.5rem,3.5vw,2.25rem) auto 0}
:where(.cf-squeeze-optin) .sqo-env-wrap{width:min(100%,32rem);margin-inline:auto}
:where(.cf-squeeze-optin) .sqo-env{display:block;width:100%;height:auto;aspect-ratio:3/2;object-fit:contain;filter:drop-shadow(0 2px 3px oklch(from var(--sqo-sh) l c h / 0.2)) drop-shadow(0 14px 16px oklch(from var(--sqo-sh) l c h / 0.14));animation:sqo-rise .45s cubic-bezier(.2,.7,.2,1) both;transition:transform .3s cubic-bezier(.2,.7,.2,1)}
:where(.cf-squeeze-optin) .sqo-stage:hover .sqo-env{transform:translateY(-4px)}
:where(.cf-squeeze-optin) .sqo-tags{list-style:none;display:flex;flex-wrap:wrap;justify-content:center;gap:.5rem;margin:1.25rem 0 0;padding:0}
:where(.cf-squeeze-optin) .sqo-tag{display:inline-flex;align-items:center;gap:.5rem;min-height:2.5rem;padding:.375rem .875rem .375rem .375rem;border:1px solid var(--card-border,oklch(from var(--ink,#101828) l c h / 0.12));border-radius:999px;background:var(--card,#fff);box-shadow:var(--shadow-md,0 1px 2px oklch(0.22 0.03 256 / 0.22),0 4px 10px -2px oklch(0.22 0.03 256 / 0.2));color:var(--ink,#101828);font-weight:700;font-size:1rem;line-height:1.2;white-space:nowrap;animation:sqo-rise .45s cubic-bezier(.2,.7,.2,1) .07s both}
:where(.cf-squeeze-optin) .sqo-tag:nth-child(2){animation-delay:.14s}
:where(.cf-squeeze-optin) .sqo-tag:nth-child(3){animation-delay:.21s}
:where(.cf-squeeze-optin) .sqo-tag-ico{display:grid;place-items:center;flex:none;width:1.75rem;height:1.75rem;border-radius:999px;background:var(--success,#16794a);color:var(--sqo-badge-glyph,#fff)}
:where(.cf-squeeze-optin) .sqo-tag-ico svg{width:1rem;height:1rem}
@media (min-width:760px){
:where(.cf-squeeze-optin) .sqo-stage.has-image .sqo-tags{position:absolute;inset:0;display:block;margin:0;pointer-events:none}
:where(.cf-squeeze-optin) .sqo-stage.has-image .sqo-tag{position:absolute}
:where(.cf-squeeze-optin) .sqo-stage.has-image .sqo-tag:nth-child(1){left:0;top:16%;rotate:-2deg}
:where(.cf-squeeze-optin) .sqo-stage.has-image .sqo-tag:nth-child(2){right:0;top:42%;rotate:2deg}
:where(.cf-squeeze-optin) .sqo-stage.has-image .sqo-tag:nth-child(3){left:3%;bottom:14%;rotate:1deg}
}
:where(.cf-squeeze-optin) .sqo-action{width:100%;max-width:30rem;margin:clamp(1.75rem,4vw,2.5rem) auto 0}
:where(.cf-squeeze-optin) .sqo-cta{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:.6rem;width:100%;min-height:4.5rem;margin:0;padding:.85rem 1.75rem;border:1px solid oklch(from var(--sqo-btn-2) calc(l - 0.04) c h);border-radius:var(--button-radius,var(--radius,12px));background:linear-gradient(180deg,oklch(from var(--sqo-btn) calc(l + 0.04) c h),var(--sqo-btn-2));color:var(--button-ink,var(--cta-ink,#fff));font-family:var(--button-font,var(--font-display,Arial,sans-serif));font-weight:var(--button-weight,800);font-size:clamp(1.25rem,1.8vw,1.5rem);line-height:1.15;letter-spacing:-.01em;text-transform:var(--button-case,none);text-shadow:var(--button-text-shadow,none);text-wrap:balance;box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--sqo-btn) calc(l + 0.14) c h / 0.7),inset 0 -3px 0 oklch(from var(--sqo-btn) calc(l - 0.16) c h),0 1px 2px oklch(from var(--sqo-sh) l c h / 0.3),0 8px 16px -6px oklch(from var(--sqo-sh) l c h / 0.4));cursor:pointer;transition:transform .16s ease,box-shadow .16s ease,background .16s ease;-webkit-tap-highlight-color:transparent}
:where(.cf-squeeze-optin) .sqo-cta:hover:not(:disabled),:where(.cf-squeeze-optin) .sqo-cta.is-hover:not(:disabled){transform:translateY(-1px);background:linear-gradient(180deg,oklch(from var(--sqo-btn) calc(l - 0.01) c h),oklch(from var(--sqo-btn-2) calc(l - 0.05) c h));box-shadow:inset 0 1px 0 oklch(from var(--sqo-btn) calc(l + 0.1) c h / 0.6),inset 0 -3px 0 oklch(from var(--sqo-btn) calc(l - 0.2) c h),0 1px 2px oklch(from var(--sqo-sh) l c h / 0.32),0 12px 20px -6px oklch(from var(--sqo-sh) l c h / 0.45)}
:where(.cf-squeeze-optin) .sqo-cta:active:not(:disabled),:where(.cf-squeeze-optin) .sqo-cta.is-active:not(:disabled){transform:translateY(1px);background:linear-gradient(180deg,oklch(from var(--sqo-btn-2) calc(l - 0.04) c h),oklch(from var(--sqo-btn) calc(l - 0.06) c h));box-shadow:inset 0 2px 4px oklch(from var(--sqo-btn) calc(l - 0.25) c h / 0.45),inset 0 -2px 0 oklch(from var(--sqo-btn) calc(l - 0.16) c h),0 1px 1px oklch(from var(--sqo-sh) l c h / 0.25)}
:where(.cf-squeeze-optin) .sqo-cta:focus-visible{outline:3px solid var(--field-focus,var(--accent,#0f5fc2));outline-offset:3px}
:where(.cf-squeeze-optin) .sqo-cta:disabled:not([data-phase='pending']){opacity:.55;cursor:not-allowed}
:where(.cf-squeeze-optin) .sqo-cta[data-phase='pending']{cursor:progress}
:where(.cf-squeeze-optin) .sqo-sub{margin:.75rem 0 0;color:var(--muted,#4a5565);font-weight:600;font-size:.9375rem;line-height:1.4;text-wrap:pretty}
:where(.cf-squeeze-optin) .sqo-dialog{width:min(calc(100% - 1.5rem),31rem);max-width:none;max-height:calc(100dvh - 1.5rem);margin:auto;padding:0;border:1px solid var(--card-border,oklch(from var(--ink,#101828) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));background:var(--card,#fff);color:var(--ink,#101828);font-family:var(--font-body,Arial,sans-serif);text-align:left;overflow:auto;box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px oklch(0.22 0.03 256 / 0.22),0 12px 24px -8px oklch(0.22 0.03 256 / 0.32)))}
:where(.cf-squeeze-optin) .sqo-dialog[open]{animation:sqo-in .28s cubic-bezier(.2,.7,.2,1)}
:where(.cf-squeeze-optin) .sqo-dialog::backdrop{background:oklch(from var(--band,#0f2747) l c h / 0.62);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
:where(.cf-squeeze-optin) .sqo-head{padding:1.25rem clamp(1.25rem,3vw,1.75rem) 1.125rem;background:color-mix(in oklch,var(--ink,#101828) 4%,var(--card,#fff));border-bottom:1px solid var(--card-border,oklch(from var(--ink,#101828) l c h / 0.12))}
:where(.cf-squeeze-optin) .sqo-head-row{display:flex;align-items:flex-start;gap:1rem}
:where(.cf-squeeze-optin) .sqo-prog{flex:1;min-width:0;padding-top:.25rem}
:where(.cf-squeeze-optin) .sqo-prog-row{display:flex;align-items:baseline;justify-content:space-between;gap:.75rem;margin-bottom:.5rem}
:where(.cf-squeeze-optin) .sqo-prog-label,:where(.cf-squeeze-optin) .sqo-prog-pct{color:var(--ink,#101828);font-weight:800;font-size:1rem;line-height:1.2}
:where(.cf-squeeze-optin) .sqo-prog-pct{font-variant-numeric:tabular-nums}
:where(.cf-squeeze-optin) .sqo-track{height:.625rem;border-radius:999px;background:color-mix(in oklch,var(--ink,#101828) 12%,var(--card,#fff));overflow:hidden}
:where(.cf-squeeze-optin) .sqo-fill{display:block;height:100%;border-radius:inherit;background:linear-gradient(90deg,oklch(from var(--accent-fill,var(--accent,#0f5fc2)) calc(l + 0.06) c h),var(--accent-fill,var(--accent,#0f5fc2)));transition:width .5s cubic-bezier(.2,.7,.2,1)}
:where(.cf-squeeze-optin) .sqo-close{display:grid;place-items:center;flex:none;width:2.75rem;height:2.75rem;margin:0;padding:0;border:1px solid var(--button-2-border,transparent);border-radius:var(--button-radius,var(--radius,12px));background:var(--button-2-bg,var(--secondary,#e8ecf3));color:var(--button-2-ink,var(--secondary-ink,var(--ink,#101828)));box-shadow:var(--button-2-shadow, var(--shadow-sm));cursor:pointer;transition:background .16s ease,transform .16s ease}
:where(.cf-squeeze-optin) .sqo-close svg{width:1.25rem;height:1.25rem}
:where(.cf-squeeze-optin) .sqo-close:hover:not(:disabled){background:oklch(from var(--button-2-bg,var(--secondary,#e8ecf3)) calc(l - 0.04) c h)}
:where(.cf-squeeze-optin) .sqo-close:active:not(:disabled){transform:translateY(1px)}
:where(.cf-squeeze-optin) .sqo-close:focus-visible{outline:3px solid var(--field-focus,var(--accent,#0f5fc2));outline-offset:2px}
:where(.cf-squeeze-optin) .sqo-close:disabled{opacity:.5;cursor:not-allowed}
:where(.cf-squeeze-optin) .sqo-steps{list-style:none;display:grid;grid-template-columns:1fr 1fr;gap:.25rem;margin:1rem 0 0;padding:.25rem;border-radius:var(--radius,12px);background:color-mix(in oklch,var(--ink,#101828) 7%,var(--card,#fff))}
:where(.cf-squeeze-optin) .sqo-step{display:flex;align-items:center;justify-content:center;gap:.5rem;min-height:2.75rem;padding:.375rem .75rem;border-radius:calc(var(--radius,12px) - 4px);color:var(--ink,#101828);font-weight:700;font-size:.9375rem;line-height:1.15;text-align:center}
:where(.cf-squeeze-optin) .sqo-step.is-current{background:var(--band,#0f2747);color:var(--band-ink,#fff);box-shadow:var(--shadow-sm,0 1px 1px oklch(0.22 0.03 256 / 0.18),0 1px 3px oklch(0.22 0.03 256 / 0.14))}
:where(.cf-squeeze-optin) .sqo-step-num{display:grid;place-items:center;flex:none;width:1.5rem;height:1.5rem;border-radius:999px;font-size:.875rem;font-weight:800;font-variant-numeric:tabular-nums}
:where(.cf-squeeze-optin) .sqo-step-num svg{width:.875rem;height:.875rem}
:where(.cf-squeeze-optin) .sqo-step.is-done .sqo-step-num{background:var(--success,#16794a);color:var(--sqo-badge-glyph,#fff)}
:where(.cf-squeeze-optin) .sqo-step.is-current .sqo-step-num{background:var(--band-ink,#fff);color:var(--band,#0f2747)}
:where(.cf-squeeze-optin) .sqo-body{padding:clamp(1.25rem,3vw,1.75rem)}
:where(.cf-squeeze-optin) .sqo-dt{margin:0;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight,800);font-size:clamp(1.75rem,3.6vw,2.25rem);line-height:1.06;letter-spacing:var(--display-tracking,-.025em);color:var(--ink,#101828);text-transform:var(--display-case,none);text-wrap:balance}
:where(.cf-squeeze-optin) .sqo-dd{margin:.5rem 0 0;color:var(--muted,#4a5565);font-weight:500;font-size:1.0625rem;line-height:1.4;text-wrap:pretty}
:where(.cf-squeeze-optin) .sqo-formerr{display:flex;align-items:flex-start;gap:.5rem;margin:1rem 0 0;padding:.75rem 1rem;border:1px solid oklch(from var(--danger,#b42318) l c h / 0.4);border-radius:10px;background:var(--danger-soft,#fdecec);color:var(--danger,#b42318);font-weight:700;font-size:.9375rem;line-height:1.4}
:where(.cf-squeeze-optin) .sqo-formerr svg{width:1.125rem;height:1.125rem;flex:none;margin-top:.1rem}
:where(.cf-squeeze-optin) .sqo-form{display:grid;gap:1rem;margin:1.5rem 0 0}
:where(.cf-squeeze-optin) .sqo-field label{display:block;margin:0 0 .5rem;color:var(--label-ink,var(--ink,#101828));font-weight:700;font-size:1.0625rem;line-height:1.3}
:where(.cf-squeeze-optin) .sqo-field input{display:block;width:100%;min-height:3.5rem;margin:0;padding:.75rem 1rem;border:1px solid var(--field-border,color-mix(in oklch,var(--ink,#101828) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));background:var(--field,#fff);color:var(--field-ink,#101828);font:inherit;font-size:1.0625rem;font-weight:500;box-shadow:inset 0 1px 2px oklch(from var(--sqo-sh) l c h / 0.06);transition:border-color .16s ease,box-shadow .16s ease}
:where(.cf-squeeze-optin) .sqo-field input::placeholder{color:color-mix(in oklch,var(--field-ink,#101828) 65%,var(--field,#fff));font-weight:400;opacity:1}
:where(.cf-squeeze-optin) .sqo-field input:hover:not(:disabled):not(:focus):not([aria-invalid='true']){border-color:color-mix(in oklch,var(--field-ink,#101828) 45%,var(--field,#fff))}
:where(.cf-squeeze-optin) .sqo-field input:focus{outline:none;border-color:var(--field-focus,var(--accent,#0f5fc2));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--accent,#0f5fc2)) l c h / 0.35)}
:where(.cf-squeeze-optin) .sqo-field input[aria-invalid='true']{border-color:var(--danger,#b42318)}
:where(.cf-squeeze-optin) .sqo-field input[aria-invalid='true']:focus{box-shadow:0 0 0 3px oklch(from var(--danger,#b42318) l c h / 0.3)}
:where(.cf-squeeze-optin) .sqo-field input:disabled{opacity:.6;cursor:not-allowed}
:where(.cf-squeeze-optin) .sqo-ferr{display:flex;align-items:flex-start;gap:.4rem;margin:.5rem 0 0;color:var(--danger,#b42318);font-weight:700;font-size:.9375rem;line-height:1.35;text-wrap:pretty}
:where(.cf-squeeze-optin) .sqo-ferr svg{width:1rem;height:1rem;flex:none;margin-top:.15rem}
:where(.cf-squeeze-optin) .sqo-cta.is-form{min-height:3.5rem;margin-top:.25rem;font-size:clamp(1.125rem,1.55vw,1.375rem)}
:where(.cf-squeeze-optin) .sqo-spin{width:1.1em;height:1.1em;flex:none;animation:sqo-spin .8s linear infinite}
:where(.cf-squeeze-optin) .sqo-privacy{margin:0;color:var(--muted,#4a5565);font-weight:500;font-size:.9375rem;line-height:1.4;text-align:center;text-wrap:pretty}
:where(.cf-squeeze-optin) .sqo-privacy svg{display:inline-block;width:1em;height:1em;margin-inline-end:.4em;vertical-align:-.15em}
@media (max-width:480px){:where(.cf-squeeze-optin) .sqo-step{font-size:.875rem;padding:.375rem .5rem}}
@keyframes sqo-rise{from{opacity:.82;translate:0 8px}to{opacity:1;translate:0 0}}
@keyframes sqo-in{from{opacity:0;translate:0 8px;scale:.98}to{opacity:1;translate:0 0;scale:1}}
@keyframes sqo-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){
:where(.cf-squeeze-optin) .sqo-env,:where(.cf-squeeze-optin) .sqo-tag,:where(.cf-squeeze-optin) .sqo-dialog[open]{animation:none}
:where(.cf-squeeze-optin) .sqo-env,:where(.cf-squeeze-optin) .sqo-cta,:where(.cf-squeeze-optin) .sqo-fill,:where(.cf-squeeze-optin) .sqo-close,:where(.cf-squeeze-optin) .sqo-field input{transition:none}
:where(.cf-squeeze-optin) .sqo-stage:hover .sqo-env,:where(.cf-squeeze-optin) .sqo-cta:hover:not(:disabled),:where(.cf-squeeze-optin) .sqo-cta.is-hover:not(:disabled),:where(.cf-squeeze-optin) .sqo-cta:active:not(:disabled),:where(.cf-squeeze-optin) .sqo-cta.is-active:not(:disabled),:where(.cf-squeeze-optin) .sqo-close:active:not(:disabled){transform:none}
:where(.cf-squeeze-optin) .sqo-spin{animation-duration:1.6s}
}
`
type SqueezeOptinCopy = {
emailInvalid: string
emailRequired: string
/** Uses {label} in lower case. */
required: string
emailPlaceholder: string
namePlaceholder: string
/** Uses {label} in lower case. */
placeholder: string
progressAria: string
close: string
stepsAria: string
saving: string
saved: string
/** Uses {percent}. */
percent: string
}
const DEFAULT_COPY: SqueezeOptinCopy = {
emailInvalid: "Please enter a valid email address, like you@example.com.",
emailRequired: "Please enter your email address.",
required: "Please enter your {label}.",
emailPlaceholder: "you@example.com",
namePlaceholder: "Jane Smith",
placeholder: "Enter your {label}",
progressAria: "Registration progress",
close: "Close",
stepsAria: "Registration steps",
saving: "Saving your seat…",
saved: "Seat saved",
percent: "{percent}%",
}
function copyText(template: string, values: Record<string, string | number>) {
return template.replace(/\{(\w+)\}/g, (match, key: string) => (Object.hasOwn(values, key) ? String(values[key]) : match))
}
pieces/hero/squeeze-optin/specimen.tsx 35 lines
import __studioImage25ed579c from "../assets/49cf97beeb8c4940.webp";
import * as React from "react"
import { SqueezeOptin, type SqueezeOptinState } from "../squeeze-optin"
import { slot } from "../../slots"
import defaults from "../../studio-defaults.json"
export const states = ["default", "hover", "active", "disabled", "error"]
export default function SqueezeOptinSpecimen({ state = "default" }: { state?: string }) {
const sample = defaults.sample
const reg = sample.registration
return (
<div>
<SqueezeOptin
state={state as SqueezeOptinState}
preheadline={reg.eyebrow}
headline={reg.headline}
highlight="your first funnel"
lead={reg.lead}
productImage={slot("product", __studioImage25ed579c)}
imageAlt="An opened navy envelope with the Funnel Starter Workshop invitation card sliding out"
insideLabels={[{ label: "Your offer" }, { label: "Your page copy" }, { label: "Your next steps" }]}
insideTitle="What you walk through in the workshop"
ctaLabel={reg.label}
ctaSublabel={reg.sublabel}
formTitle="Save your seat"
formSubtitle={reg.name}
fields={sample.fields}
submitLabel={reg.label}
privacyNote={reg.privacy}
errorMessage={reg.error}
/>
</div>
)
}
| Name | Type | Details |
|---|---|---|
copy OptionalSqueezeOptin |
Partial<SqueezeOptinCopy> |
|
preheadline OptionalSqueezeOptin |
string |
|
headline RequiredSqueezeOptin |
string |
|
highlight OptionalSqueezeOptin |
string |
|
lead OptionalSqueezeOptin |
string |
|
productImage OptionalSqueezeOptin |
string |
Default legacyImage
|
image OptionalSqueezeOptin |
string |
|
imageAlt OptionalSqueezeOptin |
string |
Default ""
|
insideLabels OptionalSqueezeOptin |
(string | { label: string })[] |
Default []
|
insideTitle OptionalSqueezeOptin |
string |
Default "Inside the workshop"
|
ctaLabel OptionalSqueezeOptin |
string |
Default "Yes! Save My Seat"
|
ctaSublabel OptionalSqueezeOptin |
string |
|
formTitle OptionalSqueezeOptin |
string |
Default "Save your seat"
|
formSubtitle OptionalSqueezeOptin |
string |
|
progressLabel OptionalSqueezeOptin |
string |
Default "You’re almost in"
|
stepLabels OptionalSqueezeOptin |
[string, string] |
Default ["Seat chosen", "Your details"]
|
fields OptionalSqueezeOptin |
SqueezeOptinField[] |
Default DEFAULT_FIELDS
|
submitLabel OptionalSqueezeOptin |
string |
|
privacyNote OptionalSqueezeOptin |
string |
Default "We respect your inbox. Unsubscribe anytime."
|
successMessage OptionalSqueezeOptin |
React.ReactNode |
|
completeLabel OptionalSqueezeOptin |
string |
|
errorMessage OptionalSqueezeOptin |
string |
Default "We couldn’t complete your registration. Please try again."
|
onSubmit OptionalSqueezeOptin |
(values: Record<string, string>) => void | Promise<void> |
|
state OptionalSqueezeOptin |
SqueezeOptinState |
Default "default"
|
className OptionalSqueezeOptin |
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).
-
49cf97beeb8c4940.webp
image/webp · 985 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB