Contact Form 3
Routing switchboard contact block. Four topic tiles on an angled colour field send each visitor to the right desk.
Use it in a prompt
Use forms/contact-form-3 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/contact-form-3.tsx. - Import it and pass your copy and images (Props tab):
import { ContactForm3 } from "@/components/funneldna/forms/contact-form-3"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/forms/contact-form-3/component.tsx 856 lines
// layout: diagonal-split
// Routing switchboard contact block. Four topic tiles on an angled colour field send each visitor to the right desk.
// Picking a tile shows only that desk's questions, its reply promise and the reason it is fast, so every enquiry lands with the person who answers it.
import * as React from "react";
import {
AlertCircle,
Blocks,
CalendarClock,
Check,
ChevronDown,
Handshake,
LifeBuoy,
Loader2,
Mail,
MessageSquare,
Newspaper,
Timer,
type LucideIcon,
} from "lucide-react";
import { Pattern } from "../fx/fx";
export type ContactFieldType = "text" | "email" | "tel" | "url" | "select" | "textarea";
export type ContactField = {
/** key in the submitted values; fields that share a name keep their answer when the visitor switches topic */
name: string;
label: string;
type?: ContactFieldType;
/** example answer; a sensible default is used per type when omitted */
placeholder?: string;
/** defaults to true */
required?: boolean;
/** choices for a select */
options?: string[];
autoComplete?: string;
/** shares a row with the next half field when the form is wide enough */
half?: boolean;
/** message shown when a required field is left empty */
error?: string;
};
export type ContactTopicIcon = "sales" | "account" | "partners" | "press" | "general";
export type ContactTopic = {
id: string;
/** tile title, e.g. "Talk to sales" */
title: string;
/** one short line under the title (hidden on phones) */
blurb?: string;
icon?: ContactTopicIcon;
/** team name used in the routing line, e.g. "Sales team" */
desk?: string;
/** supplied reply promise, e.g. "Replies within the hour"; empty hides it */
responseTime?: string;
/** the reason why that desk replies fast; empty hides it */
responseNote?: string;
/** supplied opening hours for that desk; empty hides them */
hours?: string;
/** supplied inbox for that desk; empty hides it */
email?: string;
/** only these fields show while the tile is chosen */
fields: ContactField[];
/** submit button text for this topic */
submitLabel?: string;
};
export type ContactForm3Submission = { topic: string; values: Record<string, string> };
export type ContactForm3Copy = {
/** screen-reader name of the tile group */
groupLabel: string;
/** routing heading; {desk} is replaced with the topic's desk */
routeLabel: string;
/** suffix on optional field labels */
optional: string;
/** empty required text field; {label} is replaced with the field label */
required: string;
/** empty required select; {label} is replaced with the field label */
choose: string;
emailInvalid: string;
urlInvalid: string;
phoneInvalid: string;
textPlaceholder: string;
emailPlaceholder: string;
phonePlaceholder: string;
urlPlaceholder: string;
areaPlaceholder: string;
selectPlaceholder: string;
/** submit text when a topic has no submitLabel */
send: string;
/** shown under the button until the required answers are valid */
hint: string;
busy: string;
/** shown when onSubmit rejects */
failed: string;
};
export type ContactForm3State = "default" | "hover" | "active" | "disabled" | "error";
export type ContactForm3Props = {
headline?: React.ReactNode;
lead?: React.ReactNode;
/** the four (or more) desks shown as tiles */
topics?: ContactTopic[];
/** id of the tile chosen on load; defaults to the first topic */
defaultTopic?: string;
/** prefilled answers keyed by field name */
defaultValues?: Record<string, string>;
/** privacy line under the button once the form is ready; empty hides it */
note?: string;
copy?: Partial<ContactForm3Copy>;
/** receives the chosen topic id and its validated answers; return a promise to show the sending state */
onSubmit?: (submission: ContactForm3Submission) => void | Promise<unknown>;
/** forced preview state: hover/active style a ready button, error shows validation, disabled locks the form */
state?: ContactForm3State;
className?: string;
/** id on the root section, for in-page anchors */
id?: string;
};
export function ContactForm3(props: ContactForm3Props) {
const {
headline = DEFAULT_HEADLINE,
lead = DEFAULT_LEAD,
topics = DEFAULT_TOPICS,
defaultTopic,
defaultValues,
note = DEFAULT_NOTE,
copy: copyProp,
onSubmit,
state = "default",
className,
id,
} = props;
const copy: ContactForm3Copy = { ...DEFAULT_COPY, ...copyProp };
const uid = React.useId();
const mounted = React.useRef(true);
const [topicId, setTopicId] = React.useState<string>(defaultTopic ?? topics[0]?.id ?? "");
const topic: ContactTopic | undefined = topics.find((t) => t.id === topicId) ?? topics[0];
const [values, setValues] = React.useState<Record<string, string>>(() => ({ ...(defaultValues ?? {}) }));
const [touched, setTouched] = React.useState<Record<string, boolean>>(() =>
state === "error" && topic ? allTouched(topic) : {},
);
const [busy, setBusy] = React.useState(false);
const [failed, setFailed] = React.useState(false);
const locked = state === "disabled";
const valuesKey = JSON.stringify(defaultValues ?? {});
const seenValues = React.useRef(valuesKey);
const seenState = React.useRef(state);
React.useEffect(() => {
mounted.current = true;
return () => {
mounted.current = false;
};
}, []);
React.useEffect(() => {
if (seenValues.current === valuesKey) return;
seenValues.current = valuesKey;
setValues(JSON.parse(valuesKey) as Record<string, string>);
}, [valuesKey]);
React.useEffect(() => {
if (seenState.current === state) return;
seenState.current = state;
setTouched(state === "error" && topic ? allTouched(topic) : {});
setFailed(false);
}, [state, topic]);
const idFor = (name: string) => uid + "-f-" + name.replace(/[^\w-]/g, "");
const errors: Record<string, string> = {};
if (topic) {
for (const f of topic.fields) {
const message = fieldError(f, values[f.name] ?? "", copy);
if (message) errors[f.name] = message;
}
}
const valid = Object.keys(errors).length === 0;
if (!topic) return null;
const chooseTopic = (next: string) => {
setTopicId(next);
setFailed(false);
};
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (locked || busy) return;
if (!valid) {
setTouched((prev) => ({ ...prev, ...allTouched(topic) }));
const first = topic.fields.find((f) => errors[f.name]);
if (first) event.currentTarget.ownerDocument.getElementById(idFor(first.name))?.focus();
return;
}
const out: Record<string, string> = {};
for (const f of topic.fields) out[f.name] = (values[f.name] ?? "").trim();
setFailed(false);
const result: unknown = onSubmit?.({ topic: topic.id, values: out });
if (isThenable(result)) {
setBusy(true);
try {
await result;
} catch {
if (mounted.current) setFailed(true);
} finally {
if (mounted.current) setBusy(false);
}
}
};
const renderField = (f: ContactField, index: number) => {
const type = f.type ?? "text";
const fieldId = idFor(f.name);
const errorId = fieldId + "-error";
const value = values[f.name] ?? "";
const message = touched[f.name] ? errors[f.name] : undefined;
const optional = f.required === false;
const shared = {
id: fieldId,
name: f.name,
value,
disabled: locked,
required: !optional,
"aria-invalid": message ? true : undefined,
"aria-describedby": message ? errorId : undefined,
onBlur: () => setTouched((prev) => (prev[f.name] ? prev : { ...prev, [f.name]: true })),
};
const change = (next: string) => {
setValues((prev) => ({ ...prev, [f.name]: next }));
if (failed) setFailed(false);
};
let control: React.ReactNode;
if (type === "textarea") {
control = (
<textarea
{...shared}
className="cf-cf3__input cf-cf3__area"
rows={4}
placeholder={f.placeholder ?? copy.areaPlaceholder}
onChange={(e) => change(e.target.value)}
/>
);
} else if (type === "select") {
control = (
<span className="cf-cf3__ctl">
<select
{...shared}
className={"cf-cf3__input cf-cf3__select" + (value ? "" : " is-empty")}
onChange={(e) => change(e.target.value)}
>
<option value="" disabled>
{f.placeholder ?? copy.selectPlaceholder}
</option>
{(f.options ?? []).map((option) => (
<option key={option} value={option}>
{option}
</option>
))}
</select>
<ChevronDown className="cf-cf3__chev" size={20} strokeWidth={2.5} aria-hidden="true" />
</span>
);
} else {
control = (
<input
{...shared}
className="cf-cf3__input"
type={type}
inputMode={type === "email" ? "email" : type === "tel" ? "tel" : type === "url" ? "url" : undefined}
autoComplete={f.autoComplete}
placeholder={f.placeholder ?? placeholderFor(type, copy)}
onChange={(e) => change(e.target.value)}
/>
);
}
return (
<div
key={f.name}
className={"cf-cf3__f cf-cf3__rv" + (f.half ? "" : " is-full")}
style={{ "--i": index } as React.CSSProperties}
>
<label className="cf-cf3__lab" htmlFor={fieldId}>
{f.label}
{optional ? <span className="cf-cf3__opt"> {copy.optional}</span> : null}
</label>
{control}
{message ? (
<p id={errorId} className="cf-cf3__err">
<AlertCircle className="cf-cf3__inl" size={16} strokeWidth={2.5} aria-hidden="true" />
{message}
</p>
) : null}
</div>
);
};
const DeskIcon = ICONS[topic.icon ?? "general"];
const routeLine = fill(copy.routeLabel, { desk: topic.desk ?? topic.title });
const waiting = locked;
const hintText = !valid && !locked ? copy.hint : note;
const hintId = uid + "-hint";
const buttonClass =
"cf-cf3__btn" +
(waiting ? " is-wait" : "") +
(busy ? " is-busy" : "") +
(state === "hover" && !waiting ? " is-hover" : "") +
(state === "active" && !waiting ? " is-active" : "");
return (
<section id={id} className={"cf-cf3" + (className ? " " + className : "")}>
<style>{CSS}</style>
<div className="cf-cf3__field" aria-hidden="true">
<Pattern name="grid" fade="corner" tone="band-ink" />
</div>
<form className="cf-cf3__wrap" noValidate onSubmit={handleSubmit}>
<div className="cf-cf3__floor" aria-hidden="true" />
<div className="cf-cf3__switch">
<div className="cf-cf3__head">
<h2 className="cf-cf3__title">{headline}</h2>
{lead ? <p className="cf-cf3__lead">{lead}</p> : null}
</div>
<fieldset className="cf-cf3__group" disabled={locked}>
<legend className="cf-cf3__sr">{copy.groupLabel}</legend>
<div className="cf-cf3__tiles">
{topics.map((t) => {
const on = t.id === topic.id;
const Icon = ICONS[t.icon ?? "general"];
return (
<label
key={t.id}
className={"cf-cf3__tile" + (on ? " is-on" : "") + (locked ? " is-locked" : "")}
>
<input
className="cf-cf3__radio"
type="radio"
name={uid + "-topic"}
value={t.id}
checked={on}
onChange={() => chooseTopic(t.id)}
/>
<span className="cf-cf3__tileTop">
<span className="cf-cf3__ico" aria-hidden="true">
<Icon size={24} strokeWidth={2.5} />
</span>
<span className="cf-cf3__dot" aria-hidden="true">
{on ? <Check size={14} strokeWidth={3} /> : null}
</span>
</span>
<span className="cf-cf3__tt">{t.title}</span>
{t.blurb ? <span className="cf-cf3__blurb">{t.blurb}</span> : null}
{t.responseTime ? (
<span className="cf-cf3__tm">
<Timer className="cf-cf3__inl" size={16} strokeWidth={2.5} aria-hidden="true" />
{t.responseTime}
</span>
) : null}
</label>
);
})}
</div>
</fieldset>
</div>
<div className="cf-cf3__card">
<p className="cf-cf3__sr" aria-live="polite">
{routeLine}
{topic.responseTime ? ". " + topic.responseTime : ""}
</p>
<div key={topic.id}>
<div className="cf-cf3__slip cf-cf3__rv" style={{ "--i": 0 } as React.CSSProperties}>
<div className="cf-cf3__slipHead">
<span className="cf-cf3__ico is-fill" aria-hidden="true">
<DeskIcon size={24} strokeWidth={2.5} />
</span>
<h3 className="cf-cf3__desk">{routeLine}</h3>
</div>
{topic.responseTime ? (
<p className="cf-cf3__speed">
<Timer className="cf-cf3__inl" size={20} strokeWidth={2.5} aria-hidden="true" />
{topic.responseTime}
</p>
) : null}
{topic.responseNote ? <p className="cf-cf3__why">{topic.responseNote}</p> : null}
{topic.hours || topic.email ? (
<p className="cf-cf3__meta">
{topic.hours ? (
<span>
<CalendarClock className="cf-cf3__inl" size={16} strokeWidth={2.5} aria-hidden="true" />
{topic.hours}
</span>
) : null}
{topic.email ? (
<span>
<Mail className="cf-cf3__inl" size={16} strokeWidth={2.5} aria-hidden="true" />
<a className="cf-cf3__link" href={"mailto:" + topic.email}>
{topic.email}
</a>
</span>
) : null}
</p>
) : null}
</div>
<div className="cf-cf3__fields">{topic.fields.map((f, i) => renderField(f, i + 1))}</div>
</div>
<div className="cf-cf3__act">
<button
type="submit"
className={buttonClass}
disabled={locked || busy}
aria-describedby={hintText ? hintId : undefined}
aria-busy={busy || undefined}
>
{busy ? (
<>
<Loader2 className="cf-cf3__spin" size={20} strokeWidth={2.5} aria-hidden="true" />
<span>{copy.busy}</span>
</>
) : (
<span>{topic.submitLabel ?? copy.send}</span>
)}
</button>
{failed ? (
<p className="cf-cf3__fail" role="alert">
<AlertCircle className="cf-cf3__inl" size={16} strokeWidth={2.5} aria-hidden="true" />
{copy.failed}
</p>
) : null}
{hintText ? (
<p id={hintId} className="cf-cf3__hint" aria-live="polite">
{hintText}
</p>
) : null}
</div>
</div>
</form>
</section>
);
}
export default ContactForm3;
const ICONS: Record<ContactTopicIcon, LucideIcon> = {
sales: Handshake,
account: LifeBuoy,
partners: Blocks,
press: Newspaper,
general: MessageSquare,
};
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
const URL_PATTERN = /^(https?:\/\/)?[^\s./]+(\.[^\s./]+)+(\/\S*)?$/i;
const DEFAULT_HEADLINE = "Skip the queue. Reach the right person first time.";
const DEFAULT_LEAD =
"Pick what you need. You’ll see only the questions that team needs, and exactly how fast they reply.";
const DEFAULT_NOTE = "We only use your details to answer this message.";
const DEFAULT_COPY: ContactForm3Copy = {
groupLabel: "What do you need help with?",
routeLabel: "Straight to the {desk}",
optional: "(optional)",
required: "Please add your {label}.",
choose: "Choose your {label}.",
emailInvalid: "Enter an email like you@company.com.",
urlInvalid: "Enter a web address like yourcompany.com.",
phoneInvalid: "Enter a phone number with at least 7 digits.",
textPlaceholder: "Type your answer",
emailPlaceholder: "you@company.com",
phonePlaceholder: "(555) 123-4567",
urlPlaceholder: "yourcompany.com",
areaPlaceholder: "Tell us a little more…",
selectPlaceholder: "Choose one…",
send: "Send message",
hint: "Answer the required questions to send.",
busy: "Sending…",
failed: "That didn’t send. Please try again in a moment.",
};
const NAME_FIELD: ContactField = {
name: "name",
label: "Full name",
placeholder: "Jane Smith",
autoComplete: "name",
half: true,
};
const EMAIL_FIELD: ContactField = {
name: "email",
label: "Work email",
type: "email",
placeholder: "jane@company.com",
autoComplete: "email",
half: true,
};
const DEFAULT_TOPICS: ContactTopic[] = [
{
id: "sales",
title: "Talk to sales",
blurb: "See it with your numbers and get pricing.",
icon: "sales",
desk: "Sales team",
submitLabel: "Talk to sales",
fields: [
NAME_FIELD,
EMAIL_FIELD,
{ name: "company", label: "Company", placeholder: "Acme Supply Co.", autoComplete: "organization", half: true },
{ name: "teamSize", label: "Team size", type: "select", options: ["Just me", "2–10", "11–50", "51+"], half: true },
{
name: "message",
label: "What should we cover?",
type: "textarea",
required: false,
placeholder: "The problem you want to solve first",
},
],
},
{
id: "account",
title: "Help with my account",
blurb: "Billing, logins and anything not working.",
icon: "account",
desk: "Support team",
submitLabel: "Get account help",
fields: [
NAME_FIELD,
{ ...EMAIL_FIELD, label: "Account email" },
{
name: "issue",
label: "What’s it about?",
type: "select",
options: ["Billing", "Logging in", "Something isn’t working", "Something else"],
error: "Choose what it’s about.",
},
{
name: "message",
label: "What’s happening?",
type: "textarea",
placeholder: "What did you expect, and what happened instead?",
error: "Tell us what’s happening so we can fix it.",
},
],
},
{
id: "partners",
title: "Partnerships",
blurb: "Resellers, integrations and referrals.",
icon: "partners",
desk: "Partnerships team",
submitLabel: "Send to partnerships",
fields: [
NAME_FIELD,
EMAIL_FIELD,
{ name: "company", label: "Company", placeholder: "Acme Supply Co.", autoComplete: "organization", half: true },
{ name: "website", label: "Website", type: "url", required: false, placeholder: "yourcompany.com", half: true },
{
name: "message",
label: "What do you have in mind?",
type: "textarea",
placeholder: "The partnership you’d like to build",
error: "Tell us a little about the partnership.",
},
],
},
{
id: "press",
title: "Press",
blurb: "Interviews, quotes and media files.",
icon: "press",
desk: "Press team",
submitLabel: "Send press request",
fields: [
NAME_FIELD,
EMAIL_FIELD,
{ name: "outlet", label: "Publication", placeholder: "The Daily Ledger", half: true },
{ name: "deadline", label: "Your deadline", required: false, placeholder: "Friday, 5pm", half: true },
{
name: "message",
label: "What’s the story?",
type: "textarea",
placeholder: "The angle, and who you’d like to talk to",
error: "Tell us what the story is about.",
},
],
},
];
function fill(template: string, vars: Record<string, string>): string {
return template.replace(/\{(\w+)\}/g, (_, key: string) => vars[key] ?? "");
}
function lowerFirst(text: string): string {
return text ? text.charAt(0).toLowerCase() + text.slice(1) : text;
}
function allTouched(topic: ContactTopic): Record<string, boolean> {
const out: Record<string, boolean> = {};
for (const f of topic.fields) out[f.name] = true;
return out;
}
function placeholderFor(type: ContactFieldType, copy: ContactForm3Copy): string {
if (type === "email") return copy.emailPlaceholder;
if (type === "tel") return copy.phonePlaceholder;
if (type === "url") return copy.urlPlaceholder;
return copy.textPlaceholder;
}
function fieldError(f: ContactField, raw: string, copy: ContactForm3Copy): string {
const v = raw.trim();
const type = f.type ?? "text";
if (!v) {
if (f.required === false) return "";
if (f.error) return f.error;
return fill(type === "select" ? copy.choose : copy.required, { label: lowerFirst(f.label) });
}
if (type === "email" && !EMAIL_PATTERN.test(v)) return copy.emailInvalid;
if (type === "url" && !URL_PATTERN.test(v)) return copy.urlInvalid;
if (type === "tel" && v.replace(/\D/g, "").length < 7) return copy.phoneInvalid;
return "";
}
function isThenable(value: unknown): value is PromiseLike<unknown> {
return typeof value === "object" && value !== null && typeof (value as { then?: unknown }).then === "function";
}
const CSS = `
.cf-cf3{
--cf3-pt:clamp(56px,8vw,112px);
--cf3-pb:clamp(64px,8.5vw,120px);
--cf3-gut:clamp(16px,5vw,48px);
--cf3-ink:var(--ink,oklch(0.21 0.034 263));
--cf3-muted:var(--muted,oklch(0.446 0.03 258));
--cf3-card:var(--card,oklch(1 0 0));
--cf3-band:var(--band,oklch(0.273 0.067 256));
--cf3-band-ink:var(--band-ink,oklch(1 0 0));
--cf3-accent:var(--accent,oklch(0.5 0.171 257));
--cf3-fill:var(--accent-fill,var(--cf3-accent));
--cf3-fill-ink:var(--accent-fill-ink,var(--cf3-card));
--cf3-danger:var(--danger,oklch(0.5 0.17 27));
--cf3-shadow:var(--shadow,oklch(0.22 0.03 256));
--cf3-md:var(--shadow-md,0 1px 2px oklch(from var(--cf3-shadow) l c h / 0.22),0 4px 10px -2px oklch(from var(--cf3-shadow) l c h / 0.2));
--cf3-lg:var(--shadow-lg,0 2px 4px oklch(from var(--cf3-shadow) l c h / 0.22),0 12px 24px -8px oklch(from var(--cf3-shadow) l c h / 0.32));
--cf3-line:var(--card-border,oklch(from var(--cf3-ink) l c h / 0.12));
--cf3-link:color-mix(in oklch,var(--link,var(--cf3-accent)) 86%,var(--cf3-ink));
position:relative;
isolation:isolate;
overflow-x:clip;
padding:var(--cf3-pt) var(--cf3-gut) var(--cf3-pb);
background:var(--cf3-band);
color:var(--cf3-band-ink);
font-family:var(--font-body);
font-size:clamp(1.0625rem,1.25vw,1.125rem);
line-height:1.5;
}
.cf-cf3 *,.cf-cf3 *::before,.cf-cf3 *::after{box-sizing:border-box}
.cf-cf3__sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.cf-cf3__wrap{max-width:1120px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:clamp(32px,5vw,72px);align-items:start}
.cf-cf3__switch{position:relative;z-index:1;min-width:0;color:var(--cf3-band-ink)}
.cf-cf3__field{position:absolute;inset:0;z-index:0;overflow:hidden;isolation:isolate;pointer-events:none}
.cf-cf3__floor{
position:absolute;inset:0;z-index:0;pointer-events:none;
background:var(--surface,oklch(1 0 0));
clip-path:polygon(calc(50% + 150px) 0,100% 0,100% 100%,calc(50% - 40px) 100%);
}
.cf-cf3__head,.cf-cf3__group{position:relative;z-index:1}
.cf-cf3__title{
margin:0 0 16px;
font-family:var(--font-display);
font-weight:var(--display-weight,800);
letter-spacing:var(--display-tracking,-0.025em);
text-transform:var(--display-case,none);
font-size:clamp(2rem,3.6vw,3.25rem);
line-height:1.06;
color:var(--cf3-band-ink);
text-wrap:balance;
}
.cf-cf3__lead{margin:0;max-width:60ch;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--cf3-band-ink);text-wrap:pretty}
.cf-cf3__group{margin:32px 0 0;padding:0;border:0;min-width:0}
.cf-cf3__tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:1fr;gap:16px}
.cf-cf3__tile{
position:relative;display:flex;flex-direction:column;gap:8px;min-width:0;
padding:clamp(16px,2.2vw,24px);
background:var(--cf3-card);color:var(--cf3-ink);
border:1px solid var(--cf3-line);
border-radius:var(--card-radius,var(--radius,14px));
box-shadow:var(--card-shadow,var(--cf3-md));
cursor:pointer;
transition:transform .16s ease,box-shadow .16s ease,background-color .16s ease,border-color .16s ease;
}
@media (hover:hover){
.cf-cf3__tile:not(.is-on):not(.is-locked):hover{transform:translateY(-2px);box-shadow:var(--cf3-lg);border-color:oklch(from var(--cf3-ink) l c h / 0.22)}
}
.cf-cf3__tile.is-on{
transform:translateY(-4px);
background:color-mix(in oklch,var(--cf3-accent) 7%,var(--cf3-card));
border-color:var(--cf3-accent);
box-shadow:inset 0 0 0 1px var(--cf3-accent),var(--cf3-lg);
}
.cf-cf3__tile:has(.cf-cf3__radio:focus-visible){box-shadow:0 0 0 3px var(--cf3-card),0 0 0 6px var(--cf3-accent),var(--cf3-lg)}
.cf-cf3__tile.is-on:has(.cf-cf3__radio:focus-visible){box-shadow:inset 0 0 0 1px var(--cf3-accent),0 0 0 3px var(--cf3-card),0 0 0 6px var(--cf3-accent),var(--cf3-lg)}
.cf-cf3__tile.is-locked{cursor:not-allowed;background:color-mix(in oklch,var(--cf3-ink) 4%,var(--cf3-card))}
.cf-cf3__radio{position:absolute;top:0;left:0;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
.cf-cf3__tileTop{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.cf-cf3__ico{
display:grid;place-items:center;flex:none;width:48px;height:48px;border-radius:12px;
background:color-mix(in oklch,var(--cf3-ink) 6%,var(--cf3-card));
color:var(--cf3-accent);
transition:background-color .16s ease,color .16s ease;
}
.cf-cf3__tile.is-on .cf-cf3__ico,.cf-cf3__ico.is-fill{background:var(--cf3-fill);color:var(--cf3-fill-ink)}
.cf-cf3__dot{
display:grid;place-items:center;flex:none;width:24px;height:24px;border-radius:999px;
border:2px solid oklch(from var(--cf3-ink) l c h / 0.3);
background:var(--cf3-card);color:var(--cf3-fill-ink);
transition:background-color .16s ease,border-color .16s ease;
}
.cf-cf3__tile.is-on .cf-cf3__dot{background:var(--cf3-fill);border-color:var(--cf3-fill)}
.cf-cf3__tt{margin-top:8px;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance}
.cf-cf3__blurb{font-size:0.9375rem;line-height:1.4;font-weight:500;color:var(--cf3-muted);text-wrap:pretty}
.cf-cf3__tm{margin-top:auto;padding-top:4px;font-size:0.9375rem;line-height:1.35;font-weight:600;color:var(--cf3-muted);text-wrap:pretty}
.cf-cf3__tile.is-on .cf-cf3__tm{color:var(--cf3-ink)}
.cf-cf3__inl{display:inline-block;vertical-align:-0.15em;margin-inline-end:0.4em;flex:none}
.cf-cf3__tm .cf-cf3__inl,.cf-cf3__speed .cf-cf3__inl,.cf-cf3__meta .cf-cf3__inl{color:var(--cf3-accent)}
.cf-cf3__card{
position:relative;z-index:1;min-width:0;container-type:inline-size;
padding:clamp(20px,3vw,32px);
background:var(--cf3-card);color:var(--cf3-ink);
border:1px solid var(--cf3-line);
border-radius:var(--card-radius,var(--radius,14px));
box-shadow:var(--card-shadow,var(--cf3-lg));
}
.cf-cf3__slip{display:grid;gap:8px;padding:clamp(16px,2.4vw,20px);border-radius:10px;background:color-mix(in oklch,var(--cf3-ink) 4%,var(--cf3-card))}
.cf-cf3__slipHead{display:flex;align-items:center;gap:12px;min-width:0}
.cf-cf3__desk{margin:0;min-width:0;font-family:var(--font-display);font-weight:var(--display-weight,800);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;letter-spacing:-0.01em;text-wrap:balance}
.cf-cf3__speed{margin:4px 0 0;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.3;font-weight:800;color:var(--cf3-ink);text-wrap:pretty}
.cf-cf3__why{margin:0;font-size:1rem;line-height:1.5;color:var(--cf3-muted);text-wrap:pretty}
.cf-cf3__meta{margin:4px 0 0;display:flex;flex-wrap:wrap;gap:4px 16px;font-size:0.9375rem;line-height:1.4;font-weight:600;color:var(--cf3-muted)}
.cf-cf3__meta span{min-width:0;overflow-wrap:anywhere}
.cf-cf3__link{color:var(--cf3-link);text-decoration:underline;text-decoration-color:oklch(from var(--cf3-link) l c h / 0.45);text-underline-offset:0.18em}
.cf-cf3__link:hover{color:oklch(from var(--cf3-link) calc(l - 0.08) c h);text-decoration-color:currentColor}
.cf-cf3__link:focus-visible{outline:3px solid var(--cf3-accent);outline-offset:2px;border-radius:4px}
.cf-cf3__fields{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;margin-top:24px}
@container (min-width:380px){
.cf-cf3__fields{grid-template-columns:repeat(2,minmax(0,1fr))}
.cf-cf3__f.is-full{grid-column:1 / -1}
}
.cf-cf3__f{display:flex;flex-direction:column;gap:8px;min-width:0}
.cf-cf3__lab{font-size:1rem;line-height:1.3;font-weight:700;color:var(--label-ink,var(--cf3-ink))}
.cf-cf3__opt{font-weight:500;color:var(--cf3-muted)}
.cf-cf3__ctl{position:relative;display:block}
.cf-cf3__input{
display:block;width:100%;min-height:56px;padding:14px 16px;margin:0;
font:inherit;font-size:1.0625rem;line-height:1.4;
color:var(--field-ink,var(--cf3-ink));
background:var(--field,var(--cf3-card));
border:1px solid var(--field-border,color-mix(in oklch,var(--cf3-ink) 22%,transparent));
border-radius:var(--field-radius,var(--radius,12px));
appearance:none;
transition:border-color .16s ease,box-shadow .16s ease;
}
.cf-cf3__input::placeholder{color:color-mix(in oklch,var(--field-ink,var(--cf3-ink)) 65%,var(--field,var(--cf3-card)));opacity:1}
.cf-cf3__input:hover:not(:disabled):not(:focus):not([aria-invalid="true"]){border-color:color-mix(in oklch,var(--field-ink,var(--cf3-ink)) 42%,transparent)}
.cf-cf3__input:focus{outline:none;border-color:var(--field-focus,var(--cf3-accent));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--cf3-accent)) l c h / 0.35)}
.cf-cf3__input[aria-invalid="true"]{border-color:var(--cf3-danger)}
.cf-cf3__input[aria-invalid="true"]:focus{box-shadow:0 0 0 3px oklch(from var(--cf3-danger) l c h / 0.3)}
.cf-cf3__input:disabled{cursor:not-allowed;background:color-mix(in oklch,var(--field-ink,var(--cf3-ink)) 5%,var(--field,var(--cf3-card)))}
.cf-cf3__area{min-height:120px;resize:vertical}
.cf-cf3__select{padding-right:48px;cursor:pointer}
.cf-cf3__select.is-empty{color:color-mix(in oklch,var(--field-ink,var(--cf3-ink)) 65%,var(--field,var(--cf3-card)))}
.cf-cf3__select option{color:var(--field-ink,var(--cf3-ink));background:var(--field,var(--cf3-card))}
.cf-cf3__chev{position:absolute;right:16px;top:50%;transform:translateY(-50%);pointer-events:none;color:var(--field-ink,var(--cf3-ink))}
.cf-cf3__err{margin:0;font-size:0.9375rem;line-height:1.4;font-weight:600;color:var(--cf3-danger);text-wrap:pretty}
.cf-cf3__act{display:grid;gap:12px;margin-top:24px}
.cf-cf3__btn{
--cf3-b:var(--button-bg,var(--cta,oklch(0.576 0.209 29.5)));
--cf3-b2:var(--button-bg-2,var(--cta-2,oklch(0.506 0.206 29.5)));
display:flex;align-items:center;justify-content:center;gap:10px;
width:100%;min-height:64px;padding:0 28px;margin:0;border:0;
border-radius:var(--button-radius,var(--radius,12px));
background:linear-gradient(oklch(from var(--cf3-b) calc(l + 0.04) c h),oklch(from var(--cf3-b2) calc(l - 0.02) c h));
color:var(--button-ink,var(--cta-ink,oklch(1 0 0)));
font-family:var(--button-font,var(--font-display));
font-weight:var(--button-weight,800);
text-transform:var(--button-case,none);
font-size:clamp(1.125rem,1.55vw,1.375rem);
line-height:1.15;
text-align:center;
text-shadow:var(--button-text-shadow,none);
box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--cf3-b) calc(l + 0.14) c h / 0.7),inset 0 -3px 0 oklch(from var(--cf3-b) calc(l - 0.16) c h),0 1px 2px oklch(from var(--cf3-shadow) l c h / 0.3),0 8px 16px -6px oklch(from var(--cf3-shadow) l c h / 0.45));
cursor:pointer;
transition:transform .16s ease,box-shadow .16s ease,background .16s ease;
}
.cf-cf3__btn > span{min-width:0;text-wrap:balance}
@media (hover:hover){
.cf-cf3__btn:not(.is-wait):not(:disabled):hover{
transform:translateY(-1px);
background:linear-gradient(oklch(from var(--cf3-b) calc(l - 0.01) c h),oklch(from var(--cf3-b2) calc(l - 0.07) c h));
box-shadow:inset 0 1px 0 oklch(from var(--cf3-b) calc(l + 0.1) c h / 0.7),inset 0 -3px 0 oklch(from var(--cf3-b) calc(l - 0.2) c h),0 1px 2px oklch(from var(--cf3-shadow) l c h / 0.34),0 10px 18px -6px oklch(from var(--cf3-shadow) l c h / 0.52);
}
}
.cf-cf3__btn.is-hover{
transform:translateY(-1px);
background:linear-gradient(oklch(from var(--cf3-b) calc(l - 0.01) c h),oklch(from var(--cf3-b2) calc(l - 0.07) c h));
box-shadow:inset 0 1px 0 oklch(from var(--cf3-b) calc(l + 0.1) c h / 0.7),inset 0 -3px 0 oklch(from var(--cf3-b) calc(l - 0.2) c h),0 1px 2px oklch(from var(--cf3-shadow) l c h / 0.34),0 10px 18px -6px oklch(from var(--cf3-shadow) l c h / 0.52);
}
.cf-cf3__btn:not(.is-wait):not(:disabled):active,.cf-cf3__btn.is-active{
transform:translateY(1px);
background:linear-gradient(oklch(from var(--cf3-b) calc(l - 0.05) c h),oklch(from var(--cf3-b2) calc(l - 0.08) c h));
box-shadow:inset 0 2px 4px oklch(from var(--cf3-b) calc(l - 0.22) c h / 0.55),inset 0 -2px 0 oklch(from var(--cf3-b) calc(l - 0.16) c h),0 1px 2px oklch(from var(--cf3-shadow) l c h / 0.3);
}
.cf-cf3__btn:focus-visible{outline:3px solid var(--cf3-accent);outline-offset:3px}
.cf-cf3__btn.is-wait{
transform:none;
background:var(--button-2-bg,var(--secondary,color-mix(in oklch,var(--cf3-ink) 8%,var(--cf3-card))));
color:var(--button-2-ink,var(--secondary-ink,var(--cf3-ink)));
text-shadow:none;
box-shadow:none;
cursor:not-allowed;
}
.cf-cf3__btn.is-busy{cursor:progress}
.cf-cf3__spin{flex:none;animation:cf3-spin .8s linear infinite}
.cf-cf3__hint{margin:0;text-align:center;font-size:0.9375rem;line-height:1.4;font-weight:500;color:var(--cf3-muted);text-wrap:pretty}
.cf-cf3__fail{margin:0;padding:12px 16px;border-radius:10px;background:var(--danger-soft,color-mix(in oklch,var(--cf3-danger) 14%,var(--cf3-card)));color:var(--cf3-danger);font-size:0.9375rem;line-height:1.4;font-weight:600;text-wrap:pretty}
.cf-cf3__rv{animation:cf3-rise .45s cubic-bezier(.2,.7,.2,1) both;animation-delay:min(calc(var(--i,0) * .07s),.28s)}
@keyframes cf3-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cf3-spin{to{transform:rotate(360deg)}}
@media (max-width:959px){
.cf-cf3__wrap{grid-template-columns:minmax(0,1fr);gap:40px}
.cf-cf3__switch{grid-row:1;grid-column:1}
.cf-cf3__card{grid-row:2;grid-column:1}
.cf-cf3__floor{
position:relative;inset:auto;grid-row:2;grid-column:1;align-self:stretch;
margin:-40px calc(-1 * var(--cf3-gut)) calc(-1 * var(--cf3-pb));
clip-path:polygon(0 56px,100% 0,100% 100%,0 100%);
}
}
@media (max-width:599px){
.cf-cf3__group{margin-top:24px}
.cf-cf3__tiles{gap:12px}
.cf-cf3__tile{padding:16px 14px;gap:6px}
.cf-cf3__blurb{display:none}
.cf-cf3__ico{width:44px;height:44px;border-radius:10px}
.cf-cf3__dot{width:22px;height:22px}
.cf-cf3__tt{margin-top:6px;font-size:1.125rem}
.cf-cf3__tm{font-size:0.875rem}
.cf-cf3__btn{padding:0 20px}
}
@media (prefers-reduced-motion:reduce){
.cf-cf3__rv,.cf-cf3__spin{animation:none}
.cf-cf3__tile,.cf-cf3__btn,.cf-cf3__ico,.cf-cf3__dot,.cf-cf3__input{transition:none}
.cf-cf3__tile:not(.is-on):hover,.cf-cf3__btn.is-hover,.cf-cf3__btn:hover,.cf-cf3__btn:active,.cf-cf3__btn.is-active{transform:none}
}
`;
pieces/forms/contact-form-3/specimen.tsx 163 lines
import { ContactForm3, type ContactField, type ContactForm3State, type ContactTopic } from "../contact-form-3";
export const states = ["default", "hover", "active", "disabled", "error"];
const NAME: ContactField = { name: "name", label: "Full name", placeholder: "Dana Ruiz", autoComplete: "name", half: true };
const EMAIL: ContactField = {
name: "email",
label: "Work email",
type: "email",
placeholder: "dana@northpine.example",
autoComplete: "email",
half: true,
};
const COMPANY: ContactField = {
name: "company",
label: "Company",
placeholder: "North Pine Supply",
autoComplete: "organization",
half: true,
};
const TOPICS: ContactTopic[] = [
{
id: "sales",
title: "Talk to sales",
blurb: "See Ferrule with your stock and get pricing.",
icon: "sales",
desk: "Sales team",
responseTime: "Replies within the hour",
responseNote: "A product specialist watches this inbox from open to close, so your demo gets booked the same day.",
hours: "Mon–Fri, 7am–7pm CT",
email: "sales@ferrule.example",
submitLabel: "Talk to sales",
fields: [
NAME,
EMAIL,
COMPANY,
{
name: "warehouses",
label: "Warehouses you run",
type: "select",
placeholder: "Choose a range…",
options: ["1", "2–3", "4–10", "More than 10"],
error: "Choose how many warehouses you run.",
half: true,
},
{
name: "message",
label: "What should the demo cover?",
type: "textarea",
required: false,
placeholder: "e.g. barcode scanning and low-stock alerts",
},
],
},
{
id: "account",
title: "Help with my account",
blurb: "Billing, logins, scanners and sync.",
icon: "account",
desk: "Support team",
responseTime: "Replies within 4 business hours",
responseNote: "Support engineers can see your Ferrule setup, so you never have to explain it twice.",
hours: "Mon–Fri, 6am–8pm CT",
email: "support@ferrule.example",
submitLabel: "Get account help",
fields: [
NAME,
{ ...EMAIL, label: "Account email" },
{
name: "issue",
label: "What’s it about?",
type: "select",
placeholder: "Choose a topic…",
options: ["Billing or invoices", "Logging in", "Scanning or syncing", "Something else"],
error: "Choose what it’s about.",
},
{
name: "message",
label: "What’s happening?",
type: "textarea",
placeholder: "What did you expect, and what happened instead?",
error: "Tell us what’s happening so we can fix it.",
},
],
},
{
id: "partners",
title: "Partnerships",
blurb: "Resellers, integrations and 3PL referrals.",
icon: "partners",
desk: "Partnerships team",
responseTime: "Replies within 2 business days",
responseNote: "The partnerships lead reads every request personally, not a bot.",
hours: "Mon–Fri, 9am–5pm CT",
email: "partners@ferrule.example",
submitLabel: "Send to partnerships",
fields: [
NAME,
EMAIL,
COMPANY,
{ name: "website", label: "Website", type: "url", required: false, placeholder: "northpine.example", half: true },
{
name: "message",
label: "What do you have in mind?",
type: "textarea",
placeholder: "e.g. a reseller deal for 3PLs in the Midwest",
error: "Tell us a little about the partnership.",
},
],
},
{
id: "press",
title: "Press",
blurb: "Interviews, founder quotes and logo files.",
icon: "press",
desk: "Press team",
responseTime: "Replies the same business day",
responseNote: "Founder quotes, product shots and logo files are ready to send.",
hours: "Mon–Fri, 8am–6pm CT",
email: "press@ferrule.example",
submitLabel: "Send press request",
fields: [
NAME,
EMAIL,
{ name: "outlet", label: "Publication", placeholder: "Warehouse Weekly", half: true },
{ name: "deadline", label: "Your deadline", required: false, placeholder: "Friday, 5pm CT", half: true },
{
name: "message",
label: "What’s the story?",
type: "textarea",
placeholder: "The angle, and who you’d like to talk to",
error: "Tell us what the story is about.",
},
],
},
];
const READY = {
name: "Dana Ruiz",
email: "dana@northpine.example",
company: "North Pine Supply",
warehouses: "2–3",
};
const NEEDS_FIXING = {
name: "Dana Ruiz",
email: "dana@northpine",
};
export default function ContactForm3Specimen({ state = "default" }: { state?: ContactForm3State }) {
const values = state === "hover" || state === "active" ? READY : state === "error" ? NEEDS_FIXING : undefined;
return (
<ContactForm3
topics={TOPICS}
headline="Skip the queue. Reach the right Ferrule person first time."
lead="Pick what you need. You’ll see only the questions that team needs, and exactly how fast they reply."
note="Your details go to that team only. No newsletter sign-up."
defaultValues={values}
state={state}
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalContactForm3 |
React.ReactNode |
|
lead OptionalContactForm3 |
React.ReactNode |
|
topics OptionalContactForm3 |
ContactTopic[] |
|
defaultTopic OptionalContactForm3 |
string |
|
defaultValues OptionalContactForm3 |
Record<string, string> |
|
note OptionalContactForm3 |
string |
|
copy OptionalContactForm3 |
Partial<ContactForm3Copy> |
|
onSubmit OptionalContactForm3 |
(submission: ContactForm3Submission) => void | Promise<unknown> |
|
state OptionalContactForm3 |
ContactForm3State |
|
className OptionalContactForm3 |
string |
|
id OptionalContactForm3 |
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.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.