Contact Form 1
Request-a-callback block for local businesses: a numbered who / what / when path runs straight into one "Call me back" button,
Use it in a prompt
Use forms/contact-form 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.tsx. - Import it and pass your copy and images (Props tab):
import { ContactForm } from "@/components/funneldna/forms/contact-form"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/forms/contact-form/component.tsx 775 lines
// layout: path-to-action
// Request-a-callback block for local businesses: a numbered who / what / when path runs straight into one "Call me back" button,
// with the phone number and opening hours beside it for visitors who would rather ring now.
import * as React from "react";
import { AlertCircle, Check, ChevronDown, Loader2, MapPin, Phone, ShieldCheck } from "lucide-react";
export type ContactFormValues = {
name: string;
phone: string;
email: string;
topic: string;
message: string;
/** value of the chosen ContactFormTime */
time: string;
};
/** one callback window option; detail is the small time range under the label */
export type ContactFormTime = { value: string; label: string; detail?: string };
export type ContactFormHoursRow = {
days: string;
time: string;
/** JS weekday numbers (0 = Sunday) this row covers; marks the visitor's "today" row */
dayNumbers?: number[];
/** shows the hours in the muted colour */
closed?: boolean;
};
export type ContactFormCopy = {
/** titles of the three path stops: who, what, when */
steps: string[];
nameLabel: string;
namePlaceholder: string;
phoneLabel: string;
phonePlaceholder: string;
emailLabel: string;
emailPlaceholder: string;
/** suffix on optional field labels */
optional: string;
topicLabel: string;
/** disabled first option of the topic select */
topicPlaceholder: string;
messageLabel: string;
messagePlaceholder: string;
nameError: string;
phoneError: string;
/** shown when emailRequired and the field is empty */
emailError: string;
emailInvalid: string;
topicError: string;
timeError: string;
/** shown under the button when fields need fixing */
summary: string;
/** shown when onSubmit rejects */
failed: string;
/** screen-reader suffix on a completed stop */
stepDone: string;
/** phone-width prompt before the number under the lead */
quickCall: string;
};
export type ContactFormState = "default" | "hover" | "active" | "disabled" | "error";
export type ContactFormProps = {
/** main headline; the default marks its second sentence with the highlighter */
headline?: React.ReactNode;
/** one-sentence lines; the last one is set as the punch line */
lead?: React.ReactNode[];
/** options of the "what's it about" select */
topics?: string[];
/** callback windows shown as option tiles in step 3 */
times?: ContactFormTime[];
/** displayed phone number; empty hides the call link and quick-call line */
phone?: string;
/** defaults to a tel: link built from phone */
phoneHref?: string;
/** heading of the call-now column */
callHeading?: string;
callNote?: string;
/** opening hours rows; empty hides the list */
hours?: ContactFormHoursRow[];
/** chip on the row that covers the visitor's weekday */
todayLabel?: string;
/** street address under the hours; empty hides it */
address?: string;
/** scene slot: a photo of the business or its front desk */
sceneImage?: string;
sceneAlt?: string;
/** plain text under the photo */
sceneCaption?: string;
/** submit button text */
label?: string;
/** submit button text while onSubmit's promise is pending */
busyLabel?: string;
/** privacy line under the button; empty hides it */
reassurance?: string;
/** makes the email field required instead of optional */
emailRequired?: boolean;
/** labels, placeholders, validation and screen-reader copy */
copy?: Partial<ContactFormCopy>;
/** receives validated values; return a promise to show the sending state */
onSubmit?: (values: ContactFormValues) => void | Promise<unknown>;
/** forced preview state: hover/active style the button, error shows validation, disabled locks the form */
state?: ContactFormState;
className?: string;
/** id on the root section, for in-page anchors */
id?: string;
};
export function ContactForm(props: ContactFormProps) {
const {
headline = DEFAULT_HEADLINE,
lead = DEFAULT_LEAD,
topics = DEFAULT_TOPICS,
times = DEFAULT_TIMES,
phone = "(555) 014-2260",
phoneHref,
callHeading = "Rather talk to someone now?",
callNote = "Call in opening hours and we’ll talk it through.",
hours = DEFAULT_HOURS,
todayLabel = "Today",
address = "",
sceneImage,
sceneAlt = "",
sceneCaption = "",
label = "Call me back",
busyLabel = "Sending…",
reassurance = "No obligation. We only use your details to get back to you.",
emailRequired = false,
copy: copyProp,
onSubmit,
state = "default",
className,
id,
} = props;
const copy: ContactFormCopy = { ...DEFAULT_COPY, ...copyProp };
const uid = React.useId();
const fid = (key: string) => uid + "-" + key;
const formRef = React.useRef<HTMLFormElement>(null);
const mounted = React.useRef(true);
const [values, setValues] = React.useState<ContactFormValues>(EMPTY_VALUES);
const [errors, setErrors] = React.useState<FieldErrors>({});
const [attempted, setAttempted] = React.useState(false);
const [busy, setBusy] = React.useState(false);
const [failed, setFailed] = React.useState(false);
const [today, setToday] = React.useState<number | null>(null);
const disabled = state === "disabled";
const validate = (v: ContactFormValues): FieldErrors => {
const found: FieldErrors = {};
if (!v.name.trim()) found.name = copy.nameError;
if (digitCount(v.phone) < 7) found.phone = copy.phoneError;
const email = v.email.trim();
if (!email) {
if (emailRequired) found.email = copy.emailError;
} else if (!EMAIL_PATTERN.test(email)) {
found.email = copy.emailInvalid;
}
if (!v.topic) found.topic = copy.topicError;
if (!v.time) found.time = copy.timeError;
return found;
};
React.useEffect(() => {
mounted.current = true;
setToday(new Date().getDay());
return () => {
mounted.current = false;
};
}, []);
React.useEffect(() => {
if (state === "error") {
setAttempted(true);
setErrors(validate(values));
} else {
setAttempted(false);
setErrors({});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state]);
const recheck = (key: FieldKey, next: ContactFormValues) => {
const message = validate(next)[key];
setErrors((prev) => {
if (prev[key] === message) return prev;
const updated = { ...prev };
if (message) updated[key] = message;
else delete updated[key];
return updated;
});
};
const update = (key: FieldKey, value: string) => {
const next = { ...values, [key]: value };
setValues(next);
setFailed(false);
if (attempted || errors[key]) recheck(key, next);
};
const blur = (key: FieldKey) => {
if (attempted || values[key].trim()) recheck(key, values);
};
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (disabled || busy) return;
const found = validate(values);
setAttempted(true);
setErrors(found);
setFailed(false);
const first = FIELD_ORDER.find((key) => found[key]);
if (first) {
formRef.current?.querySelector<HTMLElement>('[data-field="' + first + '"]')?.focus();
return;
}
if (!onSubmit) return;
const clean: ContactFormValues = {
...values,
name: values.name.trim(),
phone: values.phone.trim(),
email: values.email.trim(),
message: values.message.trim(),
};
try {
const result = onSubmit(clean);
if (result && typeof (result as Promise<unknown>).then === "function") {
setBusy(true);
await result;
}
} catch {
if (mounted.current) setFailed(true);
} finally {
if (mounted.current) setBusy(false);
}
};
const live = validate(values);
const done = [
!disabled && !live.name && !live.phone && !live.email,
!disabled && !live.topic,
!disabled && !live.time,
];
const allDone = done[0] && done[1] && done[2];
const showSummary = attempted && Object.keys(errors).length > 0;
const tel = phoneHref || toTel(phone);
const describe = (key: FieldKey) => (errors[key] ? fid(key + "-error") : undefined);
const stepTitle = (index: number) => copy.steps[index] ?? DEFAULT_COPY.steps[index];
return (
<section id={id} className={cx("cf-contact-form", className)} aria-labelledby={fid("title")}>
<style>{CSS}</style>
<div className="cf-contact-form__wrap">
<header className="cf-contact-form__head">
<h2 id={fid("title")} className="cf-contact-form__title">
{headline}
</h2>
{lead.length > 0 ? (
<div className="cf-contact-form__lead">
{lead.map((line, index) => (
<p key={index} className={lead.length > 1 && index === lead.length - 1 ? "cf-contact-form__punch" : undefined}>
{line}
</p>
))}
</div>
) : null}
{phone ? (
<p className="cf-contact-form__quick">
{copy.quickCall}{" "}
<a className="cf-contact-form__link" href={tel}>
{phone}
</a>
</p>
) : null}
</header>
<div className="cf-contact-form__card">
<form ref={formRef} className="cf-contact-form__form" noValidate onSubmit={handleSubmit} aria-labelledby={fid("title")}>
<Stop n={1} title={stepTitle(0)} titleId={fid("s1")} done={done[0]} doneLabel={copy.stepDone}>
<div className="cf-contact-form__fields">
<Field id={fid("name")} label={copy.nameLabel} error={errors.name} errorId={fid("name-error")}>
<input
id={fid("name")}
data-field="name"
className="cf-contact-form__input"
type="text"
name="name"
autoComplete="name"
placeholder={copy.namePlaceholder}
value={values.name}
onChange={(event) => update("name", event.target.value)}
onBlur={() => blur("name")}
disabled={disabled}
aria-required="true"
aria-invalid={errors.name ? true : undefined}
aria-describedby={describe("name")}
/>
</Field>
<div className="cf-contact-form__pair">
<Field id={fid("phone")} label={copy.phoneLabel} error={errors.phone} errorId={fid("phone-error")}>
<input
id={fid("phone")}
data-field="phone"
className="cf-contact-form__input"
type="tel"
name="phone"
inputMode="tel"
autoComplete="tel"
placeholder={copy.phonePlaceholder}
value={values.phone}
onChange={(event) => update("phone", event.target.value)}
onBlur={() => blur("phone")}
disabled={disabled}
aria-required="true"
aria-invalid={errors.phone ? true : undefined}
aria-describedby={describe("phone")}
/>
</Field>
<Field
id={fid("email")}
label={copy.emailLabel}
note={emailRequired ? undefined : copy.optional}
error={errors.email}
errorId={fid("email-error")}
>
<input
id={fid("email")}
data-field="email"
className="cf-contact-form__input"
type="email"
name="email"
autoComplete="email"
placeholder={copy.emailPlaceholder}
value={values.email}
onChange={(event) => update("email", event.target.value)}
onBlur={() => blur("email")}
disabled={disabled}
aria-required={emailRequired ? "true" : undefined}
aria-invalid={errors.email ? true : undefined}
aria-describedby={describe("email")}
/>
</Field>
</div>
</div>
</Stop>
<Stop n={2} title={stepTitle(1)} titleId={fid("s2")} done={done[1]} doneLabel={copy.stepDone}>
<div className="cf-contact-form__fields">
<Field id={fid("topic")} label={copy.topicLabel} error={errors.topic} errorId={fid("topic-error")}>
<div className="cf-contact-form__select">
<select
id={fid("topic")}
data-field="topic"
className="cf-contact-form__input"
name="topic"
value={values.topic}
data-empty={values.topic ? undefined : "true"}
onChange={(event) => update("topic", event.target.value)}
onBlur={() => blur("topic")}
disabled={disabled}
aria-required="true"
aria-invalid={errors.topic ? true : undefined}
aria-describedby={describe("topic")}
>
<option value="" disabled>
{copy.topicPlaceholder}
</option>
{topics.map((topic) => (
<option key={topic} value={topic}>
{topic}
</option>
))}
</select>
<ChevronDown className="cf-contact-form__chev" size={20} strokeWidth={2.5} aria-hidden="true" />
</div>
</Field>
<Field id={fid("message")} label={copy.messageLabel} note={copy.optional} errorId={fid("message-error")}>
<textarea
id={fid("message")}
data-field="message"
className="cf-contact-form__input"
name="message"
rows={4}
placeholder={copy.messagePlaceholder}
value={values.message}
onChange={(event) => update("message", event.target.value)}
disabled={disabled}
/>
</Field>
</div>
</Stop>
<Stop n={3} title={stepTitle(2)} titleId={fid("s3")} done={done[2]} doneLabel={copy.stepDone}>
<div
className="cf-contact-form__times"
role="radiogroup"
aria-labelledby={fid("s3")}
aria-required="true"
aria-invalid={errors.time ? true : undefined}
aria-describedby={describe("time")}
data-invalid={errors.time ? "true" : undefined}
>
{times.map((option, index) => {
const selected = values.time === option.value;
return (
<label
key={option.value}
className="cf-contact-form__time"
data-selected={selected ? "true" : undefined}
data-disabled={disabled ? "true" : undefined}
>
<input
className="cf-contact-form__radio"
type="radio"
name={fid("time")}
value={option.value}
checked={selected}
onChange={() => update("time", option.value)}
disabled={disabled}
data-field={index === 0 ? "time" : undefined}
/>
<span className="cf-contact-form__time-label">{option.label}</span>
{option.detail ? <span className="cf-contact-form__time-detail">{option.detail}</span> : null}
</label>
);
})}
</div>
{errors.time ? <FieldError id={fid("time-error")}>{errors.time}</FieldError> : null}
</Stop>
<div className="cf-contact-form__stop cf-contact-form__stop--action" data-done={allDone ? "true" : "false"}>
<div className="cf-contact-form__rail" aria-hidden="true">
<span className="cf-contact-form__dot" />
</div>
<div className="cf-contact-form__body">
<button
type="submit"
className={cx(
"cf-contact-form__btn",
state === "hover" && "is-hover",
state === "active" && "is-active",
busy && "is-busy",
)}
disabled={disabled}
aria-disabled={busy ? true : undefined}
aria-busy={busy ? true : undefined}
>
{busy ? <Loader2 className="cf-contact-form__spin" size={20} strokeWidth={2.5} aria-hidden="true" /> : null}
<span>{busy ? busyLabel : label}</span>
</button>
{showSummary || failed ? (
<p className="cf-contact-form__alert" role="alert">
<AlertCircle className="cf-contact-form__inline-icon" size={16} strokeWidth={2.5} aria-hidden="true" />
{failed ? copy.failed : copy.summary}
</p>
) : null}
{reassurance ? (
<p className="cf-contact-form__reassure">
<ShieldCheck className="cf-contact-form__inline-icon" size={16} strokeWidth={2.5} aria-hidden="true" />
{reassurance}
</p>
) : null}
</div>
</div>
</form>
</div>
<aside className="cf-contact-form__info" aria-labelledby={fid("call")}>
{sceneImage ? (
<figure className="cf-contact-form__figure">
<img className="cf-contact-form__photo" src={sceneImage} alt={sceneAlt} width={720} height={480} loading="lazy" decoding="async" />
{sceneCaption ? <figcaption className="cf-contact-form__caption">{sceneCaption}</figcaption> : null}
</figure>
) : null}
<h3 id={fid("call")} className="cf-contact-form__call-title">
{callHeading}
</h3>
{phone ? (
<a className="cf-contact-form__phone" href={tel}>
<span className="cf-contact-form__disc" aria-hidden="true">
<Phone size={20} strokeWidth={2.5} />
</span>
<span className="cf-contact-form__number">{phone}</span>
</a>
) : null}
{callNote ? <p className="cf-contact-form__call-note">{callNote}</p> : null}
{hours.length > 0 ? (
<ul className="cf-contact-form__hours">
{hours.map((row) => {
const isToday = today !== null && !!row.dayNumbers && row.dayNumbers.includes(today);
return (
<li
key={row.days}
className="cf-contact-form__row"
data-today={isToday ? "true" : undefined}
data-closed={row.closed ? "true" : undefined}
>
<span className="cf-contact-form__day">
{row.days}
{isToday ? <span className="cf-contact-form__chip">{todayLabel}</span> : null}
</span>
<span className="cf-contact-form__hrs">{row.time}</span>
</li>
);
})}
</ul>
) : null}
{address ? (
<p className="cf-contact-form__addr">
<MapPin className="cf-contact-form__inline-icon" size={16} strokeWidth={2.5} aria-hidden="true" />
{address}
</p>
) : null}
</aside>
</div>
</section>
);
}
export default ContactForm;
type FieldKey = keyof ContactFormValues;
type FieldErrors = Partial<Record<FieldKey, string>>;
/** one numbered stop on the path: number (or solid success tick when done) on the rail, title and fields beside it */
function Stop({
n,
title,
titleId,
done,
doneLabel,
children,
}: {
n: number;
title: string;
titleId: string;
done: boolean;
doneLabel: string;
children: React.ReactNode;
}) {
return (
<div className="cf-contact-form__stop" data-done={done ? "true" : "false"}>
<div className="cf-contact-form__rail" aria-hidden="true">
<span className="cf-contact-form__num">
{done ? (
<span className="cf-contact-form__badge">
<Check size={16} strokeWidth={3} />
</span>
) : (
n
)}
</span>
</div>
<div className="cf-contact-form__body">
<h3 id={titleId} className="cf-contact-form__step-title">
{title}
{done ? <span className="cf-contact-form__sr"> {doneLabel}</span> : null}
</h3>
{children}
</div>
</div>
);
}
/** label + control + inline error */
function Field({
id,
label,
note,
error,
errorId,
children,
}: {
id: string;
label: string;
note?: string;
error?: string;
errorId: string;
children: React.ReactNode;
}) {
return (
<div className="cf-contact-form__field">
<label className="cf-contact-form__label" htmlFor={id}>
{label}
{note ? <span className="cf-contact-form__note"> {note}</span> : null}
</label>
{children}
{error ? <FieldError id={errorId}>{error}</FieldError> : null}
</div>
);
}
function FieldError({ id, children }: { id: string; children: React.ReactNode }) {
return (
<p id={id} className="cf-contact-form__error">
<AlertCircle className="cf-contact-form__inline-icon" size={16} strokeWidth={2.5} aria-hidden="true" />
{children}
</p>
);
}
function cx(...parts: Array<string | false | null | undefined>) {
return parts.filter(Boolean).join(" ");
}
function digitCount(value: string) {
return Array.from(value).filter((ch) => ch >= "0" && ch <= "9").length;
}
function toTel(value: string) {
return "tel:" + Array.from(value).filter((ch) => (ch >= "0" && ch <= "9") || ch === "+").join("");
}
const EMAIL_PATTERN = /^[^@ ]+@[^@ ]+[.][^@ ]+$/;
/** focus order for the first invalid field after a submit attempt */
const FIELD_ORDER: FieldKey[] = ["name", "phone", "email", "topic", "message", "time"];
const EMPTY_VALUES: ContactFormValues = { name: "", phone: "", email: "", topic: "", message: "", time: "" };
const DEFAULT_HEADLINE = (
<>
Tell us what you need. <span className="cf-contact-form__mark">We’ll call you back.</span>
</>
);
const DEFAULT_LEAD: React.ReactNode[] = [
"Skip the hold music and the phone menu.",
"Leave your number, pick a time, and we ring you.",
"Done.",
];
const DEFAULT_TOPICS = ["Book an appointment", "Get a quote", "A question about a recent visit", "Something else"];
const DEFAULT_TIMES: ContactFormTime[] = [
{ value: "morning", label: "Morning", detail: "8am – 12pm" },
{ value: "afternoon", label: "Afternoon", detail: "12pm – 4pm" },
{ value: "late", label: "Late afternoon", detail: "4pm – 6pm" },
{ value: "any", label: "Any time", detail: "First open slot" },
];
const DEFAULT_HOURS: ContactFormHoursRow[] = [
{ days: "Monday – Friday", time: "8am – 6pm", dayNumbers: [1, 2, 3, 4, 5] },
{ days: "Saturday", time: "9am – 1pm", dayNumbers: [6] },
{ days: "Sunday", time: "Closed", dayNumbers: [0], closed: true },
];
const DEFAULT_COPY: ContactFormCopy = {
steps: ["Who should we ask for?", "What can we help with?", "When should we call?"],
nameLabel: "Your name",
namePlaceholder: "Jane Smith",
phoneLabel: "Best number to call",
phonePlaceholder: "(555) 123-4567",
emailLabel: "Email",
emailPlaceholder: "you@example.com",
optional: "(optional)",
topicLabel: "What’s it about?",
topicPlaceholder: "Choose a topic…",
messageLabel: "Anything we should know?",
messagePlaceholder: "What’s going on? A sentence or two is plenty.",
nameError: "Add your name so we know who to ask for.",
phoneError: "Add a phone number we can reach you on.",
emailError: "Add your email so we can send details.",
emailInvalid: "That email doesn’t look right. Check for typos.",
topicError: "Choose what it’s about.",
timeError: "Pick a time that suits you.",
summary: "Check the highlighted fields above, then try again.",
failed: "That didn’t go through. Try again, or give us a call.",
stepDone: "(done)",
quickCall: "Rather call?",
};
const CSS = `
.cf-contact-form{--cf-cform-h3:clamp(1.3125rem,1.8vw,1.625rem);--cf-cform-line:oklch(from var(--ink,#101828) l c h / 0.14);--cf-cform-fill:var(--accent-fill,var(--accent,#1f5fd1));--cf-cform-focus:var(--field-focus,var(--accent,#1f5fd1));--cf-cform-shadow:var(--shadow,oklch(0.22 0.03 260));position:relative;background:var(--surface,#ffffff);color:var(--ink,#101828);font-family:var(--font-body,system-ui,sans-serif);padding:clamp(56px,8vw,112px) clamp(16px,5vw,48px) clamp(64px,8.5vw,120px);overflow-x:clip}
.cf-contact-form *,.cf-contact-form *::before,.cf-contact-form *::after{box-sizing:border-box}
.cf-contact-form__wrap{max-width:1120px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:"head" "form" "info";gap:32px}
.cf-contact-form__head{grid-area:head;min-width:0;animation:cf-cform-rise .45s cubic-bezier(.2,.7,.2,1) both}
.cf-contact-form__title{margin:0 0 16px;font-family:var(--font-display,inherit);font-size:clamp(2rem,3.6vw,3.25rem);line-height:1.06;font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em);text-transform:var(--display-case,none);text-wrap:balance;color:var(--ink,#101828)}
.cf-contact-form__mark{background-image:linear-gradient(color-mix(in oklch,var(--marker,#fae37c) 85%,transparent),color-mix(in oklch,var(--marker,#fae37c) 85%,transparent));background-repeat:no-repeat;background-size:100% .56em;background-position:0 86%;padding:0 .1em;margin:0 -.04em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.cf-contact-form__lead{display:grid;gap:4px}
.cf-contact-form__lead p{margin:0;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--ink,#101828);text-wrap:pretty}
.cf-contact-form__lead .cf-contact-form__punch{margin-top:8px;font-family:var(--font-display,inherit);font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-0.025em)}
.cf-contact-form__quick{margin:24px 0 0;font-size:1.0625rem;line-height:1.4;font-weight:600;color:var(--ink,#101828)}
.cf-contact-form__link{color:var(--link,var(--accent,#1f5fd1));font-weight:800;white-space:nowrap;text-decoration:underline;text-decoration-thickness:2px;text-decoration-color:oklch(from var(--link,var(--accent,#1f5fd1)) l c h / 0.45);text-underline-offset:.18em;transition:color .16s ease}
.cf-contact-form__link:hover{color:oklch(from var(--link,var(--accent,#1f5fd1)) calc(l - 0.08) c h);text-decoration-color:currentColor}
.cf-contact-form__link:focus-visible{outline:3px solid oklch(from var(--cf-cform-focus) l c h / 0.45);outline-offset:3px;border-radius:4px}
.cf-contact-form__card{grid-area:form;min-width:0;container:cf-cform / inline-size;background:var(--card,#ffffff);color:var(--ink,#101828);border:1px solid var(--card-border,oklch(from var(--ink,#101828) l c h / 0.12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-lg,0 1px 3px oklch(from var(--cf-cform-shadow) l c h / 0.22),0 12px 24px -8px oklch(from var(--cf-cform-shadow) l c h / 0.32)));padding:clamp(20px,3vw,32px);animation:cf-cform-rise .45s cubic-bezier(.2,.7,.2,1) .07s both}
.cf-contact-form__form{margin:0}
.cf-contact-form__stop{display:grid;grid-template-columns:40px minmax(0,1fr);column-gap:16px}
.cf-contact-form__rail{position:relative}
.cf-contact-form__rail::before,.cf-contact-form__rail::after{content:"";position:absolute;left:50%;width:2px;margin-left:-1px;top:40px;bottom:8px;border-radius:2px}
.cf-contact-form__rail::before{background:var(--cf-cform-line)}
.cf-contact-form__rail::after{background:var(--cf-cform-fill);transform:scaleY(0);transform-origin:top;transition:transform .45s cubic-bezier(.2,.7,.2,1)}
.cf-contact-form__stop[data-done="true"] .cf-contact-form__rail::after{transform:scaleY(1)}
.cf-contact-form__num{display:grid;place-items:center;height:32px;font-family:var(--font-display,inherit);font-size:var(--cf-cform-h3);line-height:1;font-weight:var(--display-weight,800);font-variant-numeric:tabular-nums;color:var(--accent,#1f5fd1)}
.cf-contact-form__badge{display:grid;place-items:center;width:30px;height:30px;border-radius:999px;background:var(--success,#1f7a3d);color:var(--success-ink,#ffffff);animation:cf-cform-pop .3s cubic-bezier(.2,.7,.2,1) both}
.cf-contact-form__body{min-width:0;padding-bottom:32px}
.cf-contact-form__step-title{margin:0 0 16px;padding-top:calc((32px - 1.15em) / 2);font-family:var(--font-display,inherit);font-size:var(--cf-cform-h3);line-height:1.15;font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);text-wrap:balance;color:var(--ink,#101828)}
.cf-contact-form__stop--action .cf-contact-form__body{padding-bottom:0}
.cf-contact-form__stop:has(+ .cf-contact-form__stop--action) .cf-contact-form__rail::before,.cf-contact-form__stop:has(+ .cf-contact-form__stop--action) .cf-contact-form__rail::after{bottom:0}
.cf-contact-form__stop--action .cf-contact-form__rail::before,.cf-contact-form__stop--action .cf-contact-form__rail::after{top:0;bottom:auto;height:26px}
.cf-contact-form__dot{position:absolute;top:26px;left:50%;width:12px;height:12px;margin-left:-6px;border-radius:999px;background:var(--card,#ffffff);box-shadow:inset 0 0 0 2px var(--cf-cform-line);transition:background .3s ease,box-shadow .3s ease}
.cf-contact-form__stop--action[data-done="true"] .cf-contact-form__dot{background:var(--cf-cform-fill);box-shadow:inset 0 0 0 2px var(--cf-cform-fill)}
.cf-contact-form__fields{display:grid;gap:16px}
.cf-contact-form__pair{display:grid;gap:16px;grid-template-columns:minmax(0,1fr)}
.cf-contact-form__field{display:grid;gap:8px;min-width:0;align-content:start}
.cf-contact-form__label{font-size:1rem;line-height:1.3;font-weight:700;color:var(--label-ink,var(--ink,#101828))}
.cf-contact-form__note{font-size:.9375rem;font-weight:500;color:var(--muted,#475467)}
.cf-contact-form__input{display:block;width:100%;min-height:56px;margin:0;padding:0 16px;font:inherit;font-size:1.0625rem;line-height:1.4;color:var(--field-ink,#101828);background:var(--field,#ffffff);border:1px solid var(--field-border,color-mix(in oklch,var(--ink,#101828) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));-webkit-appearance:none;appearance:none;transition:border-color .16s ease,box-shadow .16s ease}
.cf-contact-form__input::placeholder{color:color-mix(in oklch,var(--field-ink,#101828) 65%,var(--field,#ffffff));opacity:1}
.cf-contact-form__input:hover:not(:disabled):not(:focus):not([aria-invalid="true"]){border-color:color-mix(in oklch,var(--field-ink,#101828) 45%,var(--field,#ffffff))}
.cf-contact-form__input:focus{outline:none;border-color:var(--cf-cform-focus);box-shadow:0 0 0 3px oklch(from var(--cf-cform-focus) l c h / 0.35)}
.cf-contact-form__input[aria-invalid="true"]{border-color:var(--danger,#c0362c)}
.cf-contact-form__input[aria-invalid="true"]:focus{box-shadow:0 0 0 3px oklch(from var(--danger,#c0362c) l c h / 0.3)}
.cf-contact-form__input:disabled{cursor:not-allowed;background:color-mix(in oklch,var(--field-ink,#101828) 5%,var(--field,#ffffff))}
textarea.cf-contact-form__input{min-height:120px;padding:14px 16px;line-height:1.5;resize:vertical}
.cf-contact-form__select{position:relative}
.cf-contact-form__select .cf-contact-form__input{padding-right:48px;cursor:pointer}
.cf-contact-form__select .cf-contact-form__input:disabled{cursor:not-allowed}
.cf-contact-form__select .cf-contact-form__input[data-empty="true"]{color:color-mix(in oklch,var(--field-ink,#101828) 65%,var(--field,#ffffff))}
.cf-contact-form__select option{color:var(--field-ink,#101828);background:var(--field,#ffffff)}
.cf-contact-form__chev{position:absolute;right:16px;top:50%;margin-top:-10px;color:var(--field-ink,#101828);pointer-events:none}
.cf-contact-form__error{margin:0;font-size:.9375rem;line-height:1.4;font-weight:600;color:var(--danger,#c0362c);text-wrap:pretty}
.cf-contact-form__inline-icon{display:inline-block;vertical-align:-0.15em;margin-inline-end:.4em}
.cf-contact-form__times{display:grid;gap:12px;grid-template-columns:repeat(2,minmax(0,1fr))}
.cf-contact-form__times + .cf-contact-form__error{margin-top:12px}
.cf-contact-form__time{position:relative;display:grid;align-content:center;gap:4px;min-height:72px;padding:12px 16px;border-radius:var(--field-radius,var(--radius,12px));background:color-mix(in oklch,var(--ink,#101828) 4%,var(--card,#ffffff));border:1px solid oklch(from var(--ink,#101828) l c h / 0.12);cursor:pointer;transition:border-color .16s ease,background .16s ease,box-shadow .16s ease,transform .16s ease}
.cf-contact-form__time:hover:not([data-disabled]):not([data-selected]){border-color:oklch(from var(--ink,#101828) l c h / 0.32)}
.cf-contact-form__time[data-selected]{background:color-mix(in oklch,var(--accent,#1f5fd1) 10%,var(--card,#ffffff));border-color:var(--accent,#1f5fd1);box-shadow:inset 0 0 0 1px var(--accent,#1f5fd1),var(--shadow-sm,0 1px 2px oklch(from var(--cf-cform-shadow) l c h / 0.2));transform:translateY(-1px)}
.cf-contact-form__times[data-invalid] .cf-contact-form__time{border-color:var(--danger,#c0362c)}
.cf-contact-form__time:has(.cf-contact-form__radio:focus-visible){outline:3px solid oklch(from var(--cf-cform-focus) l c h / 0.45);outline-offset:2px}
.cf-contact-form__time:active:not([data-disabled]){transform:translateY(1px)}
.cf-contact-form__time[data-disabled]{cursor:not-allowed;background:color-mix(in oklch,var(--ink,#101828) 2%,var(--card,#ffffff));border-color:oklch(from var(--ink,#101828) l c h / 0.08)}
.cf-contact-form__time[data-disabled] .cf-contact-form__time-label{color:var(--muted,#475467)}
.cf-contact-form__radio,.cf-contact-form__sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}
.cf-contact-form__radio{accent-color:var(--field-focus,var(--accent,#1f5fd1));color:var(--field-ink,var(--ink,#101828))}
.cf-contact-form__time-label{font-size:1rem;line-height:1.2;font-weight:800;color:var(--ink,#101828);text-wrap:balance}
.cf-contact-form__time-detail{font-size:.9375rem;line-height:1.3;font-weight:500;color:var(--muted,#475467);font-variant-numeric:tabular-nums}
.cf-contact-form__btn{--cf-cform-bg:var(--button-bg,var(--cta,#d7392b));--cf-cform-bg2:var(--button-bg-2,var(--cta-2,#b52e22));display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:64px;margin:0;padding:0 28px;border:0;border-radius:var(--button-radius,var(--radius,12px));font-family:var(--button-font,var(--font-display,inherit));font-size:clamp(1.125rem,1.55vw,1.375rem);line-height:1.15;font-weight:var(--button-weight,800);text-transform:var(--button-case,none);color:var(--button-ink,var(--cta-ink,#ffffff));text-shadow:var(--button-text-shadow,none);white-space:nowrap;background:linear-gradient(oklch(from var(--cf-cform-bg) calc(l + 0.04) c h),oklch(from var(--cf-cform-bg2) calc(l - 0.02) c h));box-shadow:var(--button-shadow,inset 0 1px 0 oklch(from var(--cf-cform-bg) calc(l + 0.14) c h / 0.7),inset 0 -3px 0 oklch(from var(--cf-cform-bg) calc(l - 0.16) c h),0 1px 2px oklch(from var(--cf-cform-shadow) l c h / 0.3),0 8px 16px -6px oklch(from var(--cf-cform-shadow) l c h / 0.36));cursor:pointer;transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
.cf-contact-form__btn:hover:not(:disabled),.cf-contact-form__btn.is-hover:not(:disabled){background:linear-gradient(oklch(from var(--cf-cform-bg) calc(l - 0.01) c h),oklch(from var(--cf-cform-bg2) calc(l - 0.07) c h));box-shadow:inset 0 1px 0 oklch(from var(--cf-cform-bg) calc(l + 0.12) c h / 0.7),inset 0 -3px 0 oklch(from var(--cf-cform-bg) calc(l - 0.2) c h),0 1px 2px oklch(from var(--cf-cform-shadow) l c h / 0.32),0 10px 20px -6px oklch(from var(--cf-cform-shadow) l c h / 0.44);transform:translateY(-1px)}
.cf-contact-form__btn:active:not(:disabled),.cf-contact-form__btn.is-active:not(:disabled){background:linear-gradient(oklch(from var(--cf-cform-bg) calc(l - 0.04) c h),oklch(from var(--cf-cform-bg2) calc(l - 0.08) c h));box-shadow:inset 0 2px 4px oklch(from var(--cf-cform-bg) calc(l - 0.22) c h / 0.55),inset 0 -2px 0 oklch(from var(--cf-cform-bg) calc(l - 0.16) c h),0 1px 2px oklch(from var(--cf-cform-shadow) l c h / 0.3);transform:translateY(1px)}
.cf-contact-form__btn:focus-visible{outline:3px solid oklch(from var(--cf-cform-focus) l c h / 0.55);outline-offset:3px}
.cf-contact-form__btn:disabled{background:var(--button-2-bg,var(--secondary,#e6e9ef));color:var(--button-2-ink,var(--secondary-ink,#101828));text-shadow:none;box-shadow:var(--button-2-shadow, var(--shadow-sm));cursor:not-allowed;transform:none}
.cf-contact-form__btn.is-busy{cursor:progress}
.cf-contact-form__spin{flex:0 0 auto;animation:cf-cform-spin .8s linear infinite}
.cf-contact-form__alert{margin:12px 0 0;padding:12px 16px;border-radius:10px;background:var(--danger-soft,#fbe9e7);color:var(--danger,#c0362c);font-size:.9375rem;line-height:1.4;font-weight:600;text-wrap:pretty}
.cf-contact-form__reassure{margin:12px 0 0;text-align:center;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted,#475467);text-wrap:pretty}
.cf-contact-form__reassure .cf-contact-form__inline-icon{color:var(--success,#1f7a3d)}
.cf-contact-form__info{grid-area:info;min-width:0;animation:cf-cform-rise .45s cubic-bezier(.2,.7,.2,1) .14s both}
.cf-contact-form__figure{margin:0 0 32px}
.cf-contact-form__photo{display:block;width:100%;height:auto;aspect-ratio:3 / 2;object-fit:cover;object-position:50% 35%;border-radius:12px;background:color-mix(in oklch,var(--ink,#101828) 6%,var(--surface,#ffffff))}
.cf-contact-form__caption{margin:12px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted,#475467);text-wrap:pretty}
.cf-contact-form__call-title{margin:0 0 16px;font-family:var(--font-display,inherit);font-size:var(--cf-cform-h3);line-height:1.15;font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);text-wrap:balance;color:var(--ink,#101828)}
.cf-contact-form__phone{display:inline-flex;align-items:center;gap:12px;max-width:100%;color:var(--link,var(--accent,#1f5fd1));text-decoration:none}
.cf-contact-form__phone:focus-visible{outline:3px solid oklch(from var(--cf-cform-focus) l c h / 0.45);outline-offset:4px;border-radius:12px}
.cf-contact-form__disc{flex:0 0 auto;display:grid;place-items:center;width:40px;height:40px;border-radius:999px;background:var(--accent-fill,var(--accent,#1f5fd1));color:var(--accent-fill-ink,var(--card,#ffffff))}
.cf-contact-form__number{font-family:var(--font-display,inherit);font-size:clamp(2rem,2.6vw,2.5rem);line-height:1;font-weight:var(--display-weight,800);letter-spacing:-0.03em;font-variant-numeric:tabular-nums;white-space:nowrap;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:.16em;text-decoration-color:oklch(from var(--link,var(--accent,#1f5fd1)) l c h / 0.35);transition:color .16s ease,text-decoration-color .16s ease}
.cf-contact-form__phone:hover .cf-contact-form__number{color:oklch(from var(--link,var(--accent,#1f5fd1)) calc(l - 0.08) c h);text-decoration-color:currentColor}
.cf-contact-form__call-note{margin:12px 0 0;font-size:1.0625rem;line-height:1.5;color:var(--muted,#475467);text-wrap:pretty}
.cf-contact-form__hours{list-style:none;margin:24px 0 0;padding:8px;display:grid;gap:4px;border-radius:var(--card-radius,var(--radius,14px));background:color-mix(in oklch,var(--ink,#101828) 4%,var(--surface,#ffffff))}
.cf-contact-form__row{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px 16px;min-height:48px;padding:12px 16px;border-radius:10px;font-size:1.0625rem;line-height:1.4}
.cf-contact-form__row[data-today]{background:color-mix(in oklch,var(--accent-fill,var(--accent,#1f5fd1)) 10%,var(--surface,#ffffff))}
.cf-contact-form__day{display:inline-flex;align-items:center;flex-wrap:wrap;gap:8px;font-weight:700;color:var(--ink,#101828)}
.cf-contact-form__hrs{font-weight:500;font-variant-numeric:tabular-nums;color:var(--ink,#101828)}
.cf-contact-form__row[data-closed] .cf-contact-form__hrs{color:var(--muted,#475467)}
.cf-contact-form__chip{display:inline-flex;align-items:center;min-height:28px;padding:4px 12px;border-radius:999px;font-size:.875rem;line-height:1.2;font-weight:800;background:var(--accent-fill,var(--accent,#1f5fd1));color:var(--accent-fill-ink,var(--card,#ffffff))}
.cf-contact-form__addr{margin:16px 0 0;font-size:.9375rem;line-height:1.4;font-weight:500;color:var(--muted,#475467);text-wrap:pretty}
@keyframes cf-cform-rise{from{opacity:.82;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cf-cform-pop{from{transform:scale(.9)}to{transform:scale(1)}}
@keyframes cf-cform-spin{to{transform:rotate(360deg)}}
@container cf-cform (min-width:500px){.cf-contact-form__pair{grid-template-columns:repeat(2,minmax(0,1fr))}}
@container cf-cform (max-width:440px){.cf-contact-form__stop{grid-template-columns:28px minmax(0,1fr);column-gap:12px}.cf-contact-form__badge{width:28px;height:28px}.cf-contact-form__times{grid-template-columns:minmax(0,1fr);gap:8px}.cf-contact-form__time{grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:12px;min-height:56px;padding:12px 16px}.cf-contact-form__time-label{text-wrap:nowrap}.cf-contact-form__time-detail{text-align:right;white-space:nowrap}}
@media (min-width:900px){.cf-contact-form__wrap{grid-template-columns:minmax(0,0.92fr) minmax(0,1.08fr);grid-template-areas:"head form" "info form";grid-template-rows:auto 1fr;column-gap:clamp(32px,5vw,72px);row-gap:40px;align-items:start}.cf-contact-form__quick{display:none}}
@media (prefers-reduced-motion:reduce){.cf-contact-form__head,.cf-contact-form__card,.cf-contact-form__info,.cf-contact-form__badge,.cf-contact-form__spin{animation:none}.cf-contact-form__rail::after,.cf-contact-form__dot,.cf-contact-form__btn,.cf-contact-form__input,.cf-contact-form__time,.cf-contact-form__link,.cf-contact-form__number{transition:none}.cf-contact-form__btn:hover:not(:disabled),.cf-contact-form__btn.is-hover:not(:disabled),.cf-contact-form__btn:active:not(:disabled),.cf-contact-form__btn.is-active:not(:disabled),.cf-contact-form__time[data-selected],.cf-contact-form__time:active:not([data-disabled]){transform:none}}
`;
pieces/forms/contact-form/specimen.tsx 18 lines
import sceneImage from "../assets/3f79d3ee9bc11d83.webp";
import { ContactForm, type ContactFormState } from "../contact-form";
import { slot } from "../../slots";
export const states = ["default", "hover", "active", "disabled", "error"];
export default function ContactFormSpecimen({ state }: { state?: ContactFormState }) {
return (
<ContactForm
state={state}
phone="(555) 014-2260"
address="214 Harbor Street, Riverton"
sceneImage={slot("scene", sceneImage)}
sceneAlt="Front-desk team member smiling while answering the phone"
sceneCaption="A real person at the front desk picks up, not a phone menu."
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalContactForm |
React.ReactNode |
|
lead OptionalContactForm |
React.ReactNode[] |
|
topics OptionalContactForm |
string[] |
|
times OptionalContactForm |
ContactFormTime[] |
|
phone OptionalContactForm |
string |
|
phoneHref OptionalContactForm |
string |
|
callHeading OptionalContactForm |
string |
|
callNote OptionalContactForm |
string |
|
hours OptionalContactForm |
ContactFormHoursRow[] |
|
todayLabel OptionalContactForm |
string |
|
address OptionalContactForm |
string |
|
sceneImage OptionalContactForm |
string |
|
sceneAlt OptionalContactForm |
string |
|
sceneCaption OptionalContactForm |
string |
|
label OptionalContactForm |
string |
|
busyLabel OptionalContactForm |
string |
|
reassurance OptionalContactForm |
string |
|
emailRequired OptionalContactForm |
boolean |
|
copy OptionalContactForm |
Partial<ContactFormCopy> |
|
onSubmit OptionalContactForm |
(values: ContactFormValues) => void | Promise<unknown> |
|
state OptionalContactForm |
ContactFormState |
|
className OptionalContactForm |
string |
|
id OptionalContactForm |
string |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-ink--button-2-shadow- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
scene- A wide atmosphere photo behind or beside the copy.
-
3f79d3ee9bc11d83.webp
image/webp · 81.3 KB