Capture Dialog 1
Opens the capture form at the visitor’s decision point, with native modal focus and Escape handling.
Use it in a prompt
Use kit/capture-dialog 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/kit/capture-dialog.tsx. - Import it and pass your copy and images (Props tab):
import { CaptureDialog } from "@/components/funneldna/kit/capture-dialog"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/kit/capture-dialog/component.tsx 62 lines
// pages: sales, opt-in, order, webinar-registration, application, upsell, downsell
// Opens the capture form at the visitor’s decision point, with native modal focus and Escape handling.
import { useId, useRef } from "react";
import type { ReactNode } from "react";
import { kitText } from "./core";
import { X } from "lucide-react";
export type CaptureDialogProps = {
trigger?: string;
title?: ReactNode;
lead?: ReactNode;
/** The capture form owns its validation and submission state. */
children: ReactNode;
openLabel?: string;
closeLabel?: string;
/** Called once after the trigger opens the native modal. */
onAction?: () => void;
/** Placement class for the trigger wrapper; the dialog remains in the top layer. */
className?: string;
};
export function CaptureDialog({
trigger = "Join the Free Workshop", title = "Map Out Your First Funnel", lead, children,
openLabel = "Open form", closeLabel = "Close dialog", onAction, className,
}: CaptureDialogProps) {
const dialog = useRef<HTMLDialogElement>(null);
const titleId = useId();
const leadId = useId();
return (<>
<style>{CAPTURE_DIALOG_CSS}</style>
<div className={["cf-capture-dialog flex max-w-full [align-self:var(--heading-align,center)]", className].filter(Boolean).join(" ")}><button type="button" onClick={() => { dialog.current?.showModal(); onAction?.(); }} aria-haspopup="dialog" className="cd-trigger flex min-h-12 max-w-[520px] items-center justify-center border-[length:var(--border-w,1px)] px-6 py-4 text-center text-[20px] leading-snug transition active:translate-y-px focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-[var(--ink)]">{kitText(trigger) || openLabel}</button></div>
<dialog ref={dialog} aria-labelledby={titleId} aria-describedby={lead ? leadId : undefined} className="cf-capture-dialog cd-pop fixed inset-0 m-auto h-fit max-h-[calc(100dvh-32px)] w-[calc(100%-32px)] max-w-[480px] overflow-y-auto overscroll-contain border p-0 backdrop:backdrop-blur-[3px]">
<div className="px-6 pb-7 pt-12 sm:px-10 sm:pb-9 sm:pt-12">
<header className="mx-auto flex flex-col items-center text-center">
<h2 id={titleId} className="mx-auto text-[clamp(1.75rem,5.4vw,2.25rem)] leading-[1.1] tracking-[var(--display-tracking,-0.015em)] text-[var(--ink)] [font-family:var(--font-display)] [font-weight:var(--display-weight,800)] [text-transform:var(--display-case,none)] [text-wrap:balance]">{title}</h2>
{lead ? <p id={leadId} className="mx-auto mt-3.5 max-w-[36ch] text-[17px] leading-[1.55] text-[var(--muted,#5b5148)] [text-wrap:pretty]">{lead}</p> : null}
</header>
<div className="mt-7 flex flex-col gap-5 [&>[data-optin]]:border-0 [&>[data-optin]]:bg-transparent [&>[data-optin]]:p-0 [&>[data-optin]]:shadow-none">{children}</div>
</div>
<button type="button" onClick={() => dialog.current?.close()} aria-label={closeLabel} className="cd-close absolute right-3 top-3 inline-flex size-11 items-center justify-center transition active:scale-95 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ink)]"><X aria-hidden strokeWidth={2.4} className="size-5" /></button>
</dialog>
</>);
}
export default CaptureDialog;
// Theme tokens keep the dialog and its slotted form on the same palette.
const CAPTURE_DIALOG_CSS = `
:where(.cf-capture-dialog) .cd-trigger,.cd-pop:where(.cf-capture-dialog) [data-optin] :is(button,a){text-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75));border-color:var(--button-bg-2,var(--cta-2));border-radius:var(--button-radius,var(--radius,14px));background:linear-gradient(180deg,oklch(from var(--button-bg,var(--cta)) l c h),oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h));color:var(--button-ink,var(--cta-ink));font-family:var(--button-font,var(--font-display));font-weight:var(--button-weight,700);text-transform:var(--button-case,none);box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / .3),inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h), 0 1px 2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.22), 0 4px 10px -2px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.2))}
:where(.cf-capture-dialog) .cd-trigger:hover,.cd-pop:where(.cf-capture-dialog) [data-optin] :is(button,a):hover{background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.06) c h)}
:where(.cf-capture-dialog) .cd-trigger:active,.cd-pop:where(.cf-capture-dialog) [data-optin] :is(button,a):active{background:oklch(from var(--button-bg,var(--cta)) calc(l - 0.10) c h);color:contrast-color(oklch(from var(--button-bg,var(--cta)) calc(l - 0.10) c h))}
.cd-pop:where(.cf-capture-dialog) [data-optin] :is(button,a)>span{opacity:1}
.cd-pop:where(.cf-capture-dialog) [data-optin] :is(button,a)>span:first-child{font-weight:inherit}
.cd-pop:where(.cf-capture-dialog){border-color:var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius,20px));background:var(--card);color:var(--ink);font-family:var(--font-body);box-shadow:var(--card-shadow,0 2px 4px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.24))}
.cd-pop:where(.cf-capture-dialog)::backdrop{background:oklch(from var(--band) l c h / 0.58)}
:where(.cf-capture-dialog) .cd-close{border:1px solid var(--button-2-border,transparent);border-radius:var(--button-radius,var(--radius,999px));background:var(--button-2-bg, var(--secondary, oklch(0.93 0.01 260)));color:var(--button-2-ink, var(--secondary-ink, var(--ink)));box-shadow:var(--button-2-shadow, var(--shadow-sm))}
:where(.cf-capture-dialog) .cd-close:hover{background:oklch(from var(--button-2-bg, var(--secondary, oklch(0.93 0.01 260))) calc(l - 0.04) c h);color:var(--button-2-ink, var(--secondary-ink, var(--ink)))}
.cd-pop:where(.cf-capture-dialog) [data-optin] input{background:var(--field);color:var(--field-ink);border-color:var(--field-border,oklch(from var(--ink) l c h / 0.22));border-radius:var(--field-radius,var(--radius,14px));font-family:var(--font-body)}
.cd-pop:where(.cf-capture-dialog) [data-optin] input:focus{border-color:var(--field-focus,var(--accent));outline-color:var(--field-focus,var(--accent))}
.cd-pop:where(.cf-capture-dialog) [data-optin] label{color:var(--label-ink,var(--ink))}
.cd-pop:where(.cf-capture-dialog) [data-form-note],.cd-pop:where(.cf-capture-dialog) [role=status] p,.cd-pop:where(.cf-capture-dialog) label span{color:var(--muted)}
.cd-pop:where(.cf-capture-dialog) [role=status]>span{background:var(--success-soft);color:var(--success)}
@media (prefers-reduced-motion: no-preference){.cd-pop:where(.cf-capture-dialog)[open]{animation:cd-pop-in .26s cubic-bezier(.2,.9,.25,1)}.cd-pop:where(.cf-capture-dialog)[open]::backdrop{animation:cd-fade-in .22s ease-out}}@keyframes cd-pop-in{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes cd-fade-in{from{opacity:0}to{opacity:1}}`;
pieces/kit/capture-dialog/specimen.tsx 15 lines
// Specimen for capture-dialog.tsx. Fictional Funnel Starter Workshop; proof remains unsupplied.
import { CaptureDialog } from "../capture-dialog";
import { Section } from "../core";
import { OptinForm } from "../optin-form";
import defaults from "../../studio-defaults.json";
export const states = ["default"];
export default function Page() {
return <>
<Section ><CaptureDialog trigger="Join the Free Workshop" title="Map Out Your First Funnel" lead={defaults.sample.registration.lead}>
<OptinForm fields={[{ label: "First name", name: "capture-first", autoComplete: "given-name" }, { label: "Email address", name: "capture-email", type: "email", autoComplete: "email" }]} button={defaults.sample.registration.label} privacy={defaults.sample.registration.privacy} />
</CaptureDialog></Section>
</>;
}
| Name | Type | Details |
|---|---|---|
trigger OptionalCaptureDialog |
string |
Default "Join the Free Workshop"
|
title OptionalCaptureDialog |
ReactNode |
Default "Map Out Your First Funnel"
|
lead OptionalCaptureDialog |
ReactNode |
|
children RequiredCaptureDialog |
ReactNode |
|
openLabel OptionalCaptureDialog |
string |
Default "Open form"
|
closeLabel OptionalCaptureDialog |
string |
Default "Close dialog"
|
onAction OptionalCaptureDialog |
() => void |
|
className OptionalCaptureDialog |
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.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
c5c36baf6b897f22.svg image/svg+xml · 236 Bytes
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB