Contact Form 4
Visit-us block for a local business: a centred promise over a full-bleed storefront photo, and one raised card breaking
Use it in a prompt
Use forms/contact-form-4 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-4.tsx. - Import it and pass your copy and images (Props tab):
import { ContactForm4 } from "@/components/funneldna/forms/contact-form-4"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/forms/contact-form-4/component.tsx 680 lines
// layout: classic-centred-stack
// Visit-us block for a local business: a centred promise over a full-bleed storefront photo, and one raised card breaking
// its edge that makes showing up easy: a live open-now line, tap-to-call, directions, this week's hours and a short note form.
import * as React from 'react';
import { AlertCircle, CalendarX, Loader2, MapPin, Phone, Route } from 'lucide-react';
export type ContactForm4Values = { name: string; email: string; message: string };
/** one row of the weekly hours; opens and closes are 24h 'HH:MM' strings */
export type ContactForm4Hours = {
/** day or day range as shown, e.g. 'Tuesday – Friday' */
label: string;
/** JS weekday numbers this row covers (0 = Sunday); drives the today highlight and the open-now line */
days: number[];
opens?: string;
closes?: string;
closed?: boolean;
};
export type ContactForm4Copy = {
/** status line pieces; {time} and {day} are replaced */
openNow: string;
closesAt: string;
opensToday: string;
opensTomorrow: string;
opensOn: string;
closedNow: string;
closedToday: string;
/** heading of today's timeline; {range} is replaced */
todayRange: string;
/** {open} and {close} are replaced */
range: string;
/** the visitor's clock beside the timeline; {time} is replaced */
nowAt: string;
closedLabel: string;
todayChip: string;
/** short weekday names, Sunday first */
dayNames: string[];
am: string;
pm: string;
nameLabel: string;
namePlaceholder: string;
emailLabel: string;
emailPlaceholder: string;
messageLabel: string;
messagePlaceholder: string;
nameError: string;
emailError: string;
emailInvalid: string;
messageError: string;
/** shown under the disabled send button until every field is valid */
incomplete: string;
busyLabel: string;
/** shown when onSubmit rejects */
failed: string;
};
export type ContactForm4State = 'default' | 'hover' | 'active' | 'disabled' | 'error';
export type ContactForm4Props = {
headline?: React.ReactNode;
/** phrase after the headline, set in the accent colour */
headlineAccent?: React.ReactNode;
lead?: React.ReactNode;
/** italic aside in the owner's voice under the lead; empty hides it */
aside?: React.ReactNode;
/** scene slot: storefront or street photo, shown full bleed */
sceneImage?: string;
sceneAlt?: string;
/** object-position of the photo */
sceneFocus?: string;
/** business name on the card; empty hides it */
name?: string;
/** address lines; empty hides the address and the default directions link */
address?: string[];
/** displayed phone number, also the call button's second line; empty hides the call button */
phone?: string;
/** defaults to a tel: link built from phone */
phoneHref?: string;
callLabel?: string;
/** defaults to a Google Maps directions link to the name and address */
directionsHref?: string;
directionsLabel?: string;
directionsNote?: string;
hoursHeading?: string;
hours?: ContactForm4Hours[];
/** holiday or closure notice under the hours; empty hides it */
closure?: string;
formHeading?: string;
formLead?: string;
submitLabel?: string;
/** second line inside the send button */
submitNote?: string;
/** privacy line under the send button once the form is complete */
privacy?: string;
copy?: Partial<ContactForm4Copy>;
/** receives trimmed, validated values; return a promise to show the sending state */
onSubmit?: (values: ContactForm4Values) => void | Promise<unknown>;
/** forced preview state: hover/active style the call button, error shows validation, disabled locks the form */
state?: ContactForm4State;
className?: string;
id?: string;
};
export function ContactForm4(props: ContactForm4Props) {
const {
headline = 'Come and see us.',
headlineAccent = 'We’re easy to find.',
lead = 'Here’s where we are, when the door is open and the quickest way to reach us.',
aside = '(Not sure if we’re open right now? The card below checks for you.)',
sceneImage,
sceneAlt = '',
sceneFocus = '50% 45%',
name = '',
address = DEFAULT_ADDRESS,
phone = '(555) 014-2260',
phoneHref,
callLabel = 'Call us',
directionsHref,
directionsLabel = 'Get directions',
directionsNote = 'Opens in Google Maps',
hoursHeading = 'Here’s when the door is open',
hours = DEFAULT_HOURS,
closure = '',
formHeading = 'Have a question before you visit?',
formLead = 'Send a quick note and we’ll reply by email.',
submitLabel = 'Send my message',
submitNote = 'Goes straight to our team',
privacy = 'We only use your email to reply to you.',
copy: copyProp,
onSubmit,
state = 'default',
className,
id,
} = props;
const copy: ContactForm4Copy = { ...DEFAULT_COPY, ...copyProp };
const uid = React.useId();
const fid = (key: string) => uid + '-' + key;
const mounted = React.useRef(true);
const [now, setNow] = React.useState<Date | null>(null);
const [values, setValues] = React.useState<ContactForm4Values>(EMPTY_VALUES);
const [touched, setTouched] = React.useState<Partial<Record<FieldKey, boolean>>>({});
const [attempted, setAttempted] = React.useState(false);
const [busy, setBusy] = React.useState(false);
const [failed, setFailed] = React.useState(false);
const locked = state === 'disabled';
const showAll = attempted || state === 'error';
React.useEffect(() => {
mounted.current = true;
const tick = () => setNow(new Date());
tick();
const timer = window.setInterval(tick, 30000);
return () => {
mounted.current = false;
window.clearInterval(timer);
};
}, []);
const errors = validate(values, copy);
const valid = Object.keys(errors).length === 0;
const status = now ? openStatus(hours, now, copy) : null;
const day = now ? now.getDay() : -1;
const todayRow = now ? hours.findIndex((row) => row.days.includes(day)) : -1;
const todaySpan = now ? spanFor(hours, day) : null;
const scale = timelineScale(hours);
const nowMinutes = now ? now.getHours() * 60 + now.getMinutes() : 0;
const pct = (minutes: number) => (scale ? ((minutes - scale.start) / (scale.end - scale.start)) * 100 : 0);
const showNow = !!scale && now !== null && nowMinutes >= scale.start && nowMinutes <= scale.end;
const time = (minutes: number) => formatTime(minutes, copy);
const rangeText = (open: number, close: number) => fill(copy.range, { open: time(open), close: time(close) });
const tel = phoneHref ?? 'tel:' + phone.replace(/[^\d+]/g, '');
const mapsHref =
directionsHref ??
(address.length
? 'https://www.google.com/maps/dir/?api=1&destination=' + encodeURIComponent([name, ...address].filter(Boolean).join(', '))
: '');
const sendNote = valid ? privacy : copy.incomplete;
const fieldProps = (key: FieldKey) => {
const show = Boolean((touched[key] || showAll) && errors[key]);
return {
id: fid(key),
name: key,
value: values[key],
onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const next = event.target.value;
setValues((current) => ({ ...current, [key]: next }));
setFailed(false);
},
onBlur: () => setTouched((current) => ({ ...current, [key]: true })),
'aria-invalid': show ? true : undefined,
'aria-describedby': show ? fid(key + '-error') : undefined,
};
};
const errorFor = (key: FieldKey) =>
(touched[key] || showAll) && errors[key] ? (
<p className='cf4-error' id={fid(key + '-error')}>
<AlertCircle size={16} strokeWidth={2.5} aria-hidden='true' />
{errors[key]}
</p>
) : null;
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (locked || busy) return;
setAttempted(true);
if (!valid) return;
setFailed(false);
const result: unknown = onSubmit?.({
name: values.name.trim(),
email: values.email.trim(),
message: values.message.trim(),
});
if (!isThenable(result)) return;
setBusy(true);
try {
await result;
} catch {
if (mounted.current) setFailed(true);
} finally {
if (mounted.current) setBusy(false);
}
};
return (
<section id={id} aria-labelledby={fid('title')} className={'cf-contact-form-4' + (className ? ' ' + className : '')}>
<style>{CSS}</style>
<header className='cf4-intro'>
<h2 id={fid('title')} className='cf4-headline cf4-reveal'>
{headline}
{headlineAccent ? (
<>
{' '}
<span className='cf4-accent'>{headlineAccent}</span>
</>
) : null}
</h2>
{lead ? (
<p className='cf4-lead cf4-reveal' style={delay(1)}>
{lead}
</p>
) : null}
{aside ? (
<p className='cf4-aside cf4-reveal' style={delay(2)}>
{aside}
</p>
) : null}
</header>
{sceneImage ? (
<div className='cf4-photo'>
<img src={sceneImage} alt={sceneAlt} width={1600} height={900} decoding='async' style={{ objectPosition: sceneFocus }} />
</div>
) : null}
<div className={'cf4-wrap' + (sceneImage ? ' is-overlap' : '')}>
<div className='cf4-card cf4-reveal' style={delay(3)}>
<div className='cf4-visit'>
<div className='cf4-info'>
<p className={'cf4-status' + (status && status.open ? ' is-open' : '')} aria-live='polite'>
{status ? (
<>
<span className='cf4-dot' aria-hidden='true' />
{status.strong === 0 ? <strong>{status.parts[0]}</strong> : status.parts[0]}
<span className='cf4-sep' aria-hidden='true'>
{' · '}
</span>
{status.strong === 1 ? <strong>{status.parts[1]}</strong> : status.parts[1]}
</>
) : null}
</p>
{name ? <h3 className='cf4-name'>{name}</h3> : null}
{address.length ? (
<address className='cf4-address'>
<MapPin size={18} strokeWidth={2.5} aria-hidden='true' />
<span>
{address.map((line, i) => (
<React.Fragment key={i}>
{i ? <br /> : null}
{line}
</React.Fragment>
))}
</span>
</address>
) : null}
{phone || mapsHref ? (
<div className='cf4-actions'>
{phone ? (
<a
href={tel}
className={'cf4-btn cf4-call' + (state === 'hover' ? ' is-hover' : '') + (state === 'active' ? ' is-active' : '')}
>
<Phone className='cf4-btn-icon' size={20} strokeWidth={2.5} aria-hidden='true' />
<span className='cf4-btn-text'>
<span className='cf4-btn-label'>{callLabel}</span>
<span className='cf4-btn-sub'>{phone}</span>
</span>
</a>
) : null}
{mapsHref ? (
<a href={mapsHref} target='_blank' rel='noopener noreferrer' className='cf4-btn cf4-dir'>
<Route className='cf4-btn-icon' size={20} strokeWidth={2.5} aria-hidden='true' />
<span className='cf4-btn-text'>
<span className='cf4-btn-label'>{directionsLabel}</span>
{directionsNote ? <span className='cf4-btn-sub'>{directionsNote}</span> : null}
</span>
</a>
) : null}
</div>
) : null}
</div>
{hours.length ? (
<div className='cf4-hours'>
<h3 className='cf4-hours-title'>{hoursHeading}</h3>
{now && scale ? (
<div className='cf4-today'>
<div className='cf4-today-head'>
<span className='cf4-today-hours'>
{todaySpan ? fill(copy.todayRange, { range: rangeText(todaySpan.open, todaySpan.close) }) : copy.closedToday}
</span>
<span className='cf4-today-now'>{fill(copy.nowAt, { time: time(nowMinutes) })}</span>
</div>
<div className='cf4-track' aria-hidden='true'>
{todaySpan ? (
<span
className='cf4-span'
style={{ left: pct(todaySpan.open) + '%', width: (pct(todaySpan.close) - pct(todaySpan.open)) + '%' }}
/>
) : null}
{showNow ? <span className='cf4-now' style={{ left: pct(nowMinutes) + '%' }} /> : null}
</div>
<div className='cf4-ticks' aria-hidden='true'>
<span>{time(scale.start)}</span>
<span>{time(scale.end)}</span>
</div>
</div>
) : null}
<dl className='cf4-list'>
{hours.map((row, i) => {
const span = spanOf(row);
const isToday = i === todayRow;
return (
<div key={row.label + i} className={'cf4-row' + (isToday ? ' is-today' : '')} aria-current={isToday ? 'date' : undefined}>
<dt>
{row.label}
{isToday ? <span className='cf4-chip'>{copy.todayChip}</span> : null}
</dt>
<dd className={span ? undefined : 'is-closed'}>{span ? rangeText(span.open, span.close) : copy.closedLabel}</dd>
</div>
);
})}
</dl>
{closure ? (
<p className='cf4-closure'>
<CalendarX size={16} strokeWidth={2.5} aria-hidden='true' />
{closure}
</p>
) : null}
</div>
) : null}
</div>
<form className='cf4-form' noValidate onSubmit={handleSubmit} aria-labelledby={fid('form-title')}>
<div className='cf4-form-intro'>
<h3 id={fid('form-title')} className='cf4-form-title'>
{formHeading}
</h3>
{formLead ? <p className='cf4-form-lead'>{formLead}</p> : null}
</div>
<fieldset className='cf4-fields' disabled={locked}>
<div className='cf4-pair'>
<div className='cf4-field'>
<label className='cf4-label' htmlFor={fid('name')}>
{copy.nameLabel}
</label>
<input className='cf4-input' type='text' autoComplete='name' placeholder={copy.namePlaceholder} {...fieldProps('name')} />
{errorFor('name')}
</div>
<div className='cf4-field'>
<label className='cf4-label' htmlFor={fid('email')}>
{copy.emailLabel}
</label>
<input
className='cf4-input'
type='email'
inputMode='email'
autoComplete='email'
placeholder={copy.emailPlaceholder}
{...fieldProps('email')}
/>
{errorFor('email')}
</div>
</div>
<div className='cf4-field'>
<label className='cf4-label' htmlFor={fid('message')}>
{copy.messageLabel}
</label>
<textarea className='cf4-input' rows={4} placeholder={copy.messagePlaceholder} {...fieldProps('message')} />
{errorFor('message')}
</div>
<div className='cf4-send'>
<button
type='submit'
className='cf4-btn cf4-submit'
disabled={!valid || locked}
aria-busy={busy || undefined}
aria-describedby={sendNote ? fid('send-note') : undefined}
>
{busy ? (
<span className='cf4-btn-text'>
<span className='cf4-btn-label'>
<Loader2 className='cf4-spin' size={20} strokeWidth={2.5} aria-hidden='true' />
{copy.busyLabel}
</span>
</span>
) : (
<span className='cf4-btn-text'>
<span className='cf4-btn-label'>{submitLabel}</span>
{submitNote ? <span className='cf4-btn-sub'>{submitNote}</span> : null}
</span>
)}
</button>
{sendNote ? (
<p id={fid('send-note')} className='cf4-note'>
{sendNote}
</p>
) : null}
{failed ? (
<p className='cf4-error' role='alert'>
<AlertCircle size={16} strokeWidth={2.5} aria-hidden='true' />
{copy.failed}
</p>
) : null}
</div>
</fieldset>
</form>
</div>
</div>
</section>
);
}
export default ContactForm4;
type FieldKey = keyof ContactForm4Values;
type Span = { open: number; close: number };
type Status = { open: boolean; parts: [string, string]; strong: 0 | 1 };
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const EMPTY_VALUES: ContactForm4Values = { name: '', email: '', message: '' };
const DEFAULT_ADDRESS = ['214 Market Street', 'Riverside'];
const DEFAULT_HOURS: ContactForm4Hours[] = [
{ label: 'Monday – Friday', days: [1, 2, 3, 4, 5], opens: '08:00', closes: '17:00' },
{ label: 'Saturday', days: [6], opens: '09:00', closes: '13:00' },
{ label: 'Sunday', days: [0], closed: true },
];
const DEFAULT_COPY: ContactForm4Copy = {
openNow: 'Open now',
closesAt: 'Closes {time}',
opensToday: 'Opens {time}',
opensTomorrow: 'Opens {time} tomorrow',
opensOn: 'Opens {day} at {time}',
closedNow: 'Closed right now',
closedToday: 'Closed today',
todayRange: 'Today, {range}',
range: '{open} – {close}',
nowAt: 'It’s {time} now',
closedLabel: 'Closed',
todayChip: 'Today',
dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
am: 'am',
pm: 'pm',
nameLabel: 'Your name',
namePlaceholder: 'Jane Smith',
emailLabel: 'Email address',
emailPlaceholder: 'you@example.com',
messageLabel: 'Your message',
messagePlaceholder: 'What would you like to ask before you come in?',
nameError: 'Please tell us your name.',
emailError: 'Please enter your email so we can reply.',
emailInvalid: 'That email doesn’t look right. Check for typos.',
messageError: 'Please write a short message.',
incomplete: 'Fill in your name, email and message to send.',
busyLabel: 'Sending…',
failed: 'Your message didn’t send. Please try again.',
};
function delay(step: number): React.CSSProperties {
return { animationDelay: Math.min(step * 0.07, 0.28) + 's' };
}
function fill(template: string, map: Record<string, string>) {
return template.replace(/\{(\w+)\}/g, (match, key: string) => (key in map ? map[key] : match));
}
function isThenable(value: unknown): value is PromiseLike<unknown> {
return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';
}
function validate(v: ContactForm4Values, copy: ContactForm4Copy) {
const found: Partial<Record<FieldKey, string>> = {};
if (!v.name.trim()) found.name = copy.nameError;
const email = v.email.trim();
if (!email) found.email = copy.emailError;
else if (!EMAIL_PATTERN.test(email)) found.email = copy.emailInvalid;
if (!v.message.trim()) found.message = copy.messageError;
return found;
}
function parseTime(value?: string): number | null {
if (!value) return null;
const match = /^(\d{1,2}):(\d{2})$/.exec(value.trim());
if (!match) return null;
const h = Number(match[1]);
const m = Number(match[2]);
if (h > 24 || m > 59) return null;
return h * 60 + m;
}
function formatTime(minutes: number, copy: ContactForm4Copy) {
const h24 = Math.floor(minutes / 60) % 24;
const m = minutes % 60;
const suffix = h24 < 12 ? copy.am : copy.pm;
const h = h24 % 12 || 12;
return m ? h + ':' + String(m).padStart(2, '0') + suffix : h + suffix;
}
function spanOf(row: ContactForm4Hours): Span | null {
if (row.closed) return null;
const open = parseTime(row.opens);
const close = parseTime(row.closes);
if (open === null || close === null || close <= open) return null;
return { open, close };
}
function spanFor(hours: ContactForm4Hours[], day: number): Span | null {
const row = hours.find((r) => r.days.includes(day));
return row ? spanOf(row) : null;
}
function timelineScale(hours: ContactForm4Hours[]) {
const spans = hours.map((row) => spanOf(row)).filter((s): s is Span => s !== null);
if (!spans.length) return null;
const start = Math.max(0, Math.floor(Math.min(...spans.map((s) => s.open)) / 60) * 60 - 60);
const end = Math.min(1440, Math.ceil(Math.max(...spans.map((s) => s.close)) / 60) * 60 + 60);
return { start, end };
}
function openStatus(hours: ContactForm4Hours[], now: Date, copy: ContactForm4Copy): Status | null {
if (!hours.some((row) => spanOf(row))) return null;
const day = now.getDay();
const minutes = now.getHours() * 60 + now.getMinutes();
const today = spanFor(hours, day);
const t = (m: number) => formatTime(m, copy);
if (today && minutes >= today.open && minutes < today.close) {
return { open: true, parts: [copy.openNow, fill(copy.closesAt, { time: t(today.close) })], strong: 0 };
}
const closedText = today ? copy.closedNow : copy.closedToday;
if (today && minutes < today.open) {
return { open: false, parts: [closedText, fill(copy.opensToday, { time: t(today.open) })], strong: 1 };
}
for (let offset = 1; offset <= 7; offset++) {
const d = (day + offset) % 7;
const next = spanFor(hours, d);
if (!next) continue;
const opens =
offset === 1
? fill(copy.opensTomorrow, { time: t(next.open) })
: fill(copy.opensOn, { day: copy.dayNames[d] ?? '', time: t(next.open) });
return { open: false, parts: [closedText, opens], strong: 1 };
}
return null;
}
const CSS = `
.cf-contact-form-4{--cf4-gutter:clamp(16px,5vw,48px);--cf4-shadow:var(--shadow,oklch(0.22 0.03 260));position:relative;background:var(--surface);color:var(--ink);font-family:var(--font-body);padding:clamp(56px,8vw,112px) 0 clamp(64px,8.5vw,120px);overflow-x:clip}
.cf-contact-form-4 *,.cf-contact-form-4 *::before,.cf-contact-form-4 *::after{box-sizing:border-box}
.cf-contact-form-4 .cf4-intro{max-width:calc(46rem + 2 * var(--cf4-gutter));margin:0 auto;padding:0 var(--cf4-gutter);text-align:center}
.cf-contact-form-4 .cf4-headline{margin:0;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;text-wrap:balance;color:var(--ink)}
.cf-contact-form-4 .cf4-accent{color:var(--accent)}
.cf-contact-form-4 .cf4-lead{margin:16px auto 0;max-width:40rem;font-size:clamp(1.125rem,1.5vw,1.375rem);line-height:1.4;font-weight:500;color:var(--ink);text-wrap:pretty}
.cf-contact-form-4 .cf4-aside{margin:12px auto 0;max-width:40rem;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;font-style:italic;color:var(--muted);text-wrap:pretty}
.cf-contact-form-4 .cf4-photo{margin-top:clamp(32px,4vw,48px);height:clamp(340px,40vw,600px);overflow:hidden;background:color-mix(in oklch,var(--ink) 6%,var(--surface))}
.cf-contact-form-4 .cf4-photo img{display:block;width:100%;height:100%;object-fit:cover}
.cf-contact-form-4 .cf4-wrap{position:relative;z-index:1;max-width:calc(1040px + 2 * var(--cf4-gutter));margin:clamp(32px,4vw,48px) auto 0;padding:0 var(--cf4-gutter)}
.cf-contact-form-4 .cf4-wrap.is-overlap{margin-top:calc(-1 * clamp(48px,12vw,180px))}
.cf-contact-form-4 .cf4-card{background:var(--card);color:var(--ink);border:1px solid var(--card-border,oklch(from var(--ink) l c h / .12));border-radius:var(--card-radius,var(--radius,14px));box-shadow:var(--card-shadow,var(--shadow-lg,0 2px 4px oklch(0.22 0.03 260 / .22),0 12px 24px -8px oklch(0.22 0.03 260 / .32)));padding:clamp(20px,3vw,40px)}
.cf-contact-form-4 .cf4-visit{display:grid;grid-template-columns:minmax(0,1fr);gap:28px;align-items:start}
.cf-contact-form-4 .cf4-info{display:flex;flex-direction:column;gap:16px;min-width:0}
.cf-contact-form-4 .cf4-status{order:0;margin:0;min-height:1.5em;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--ink);text-wrap:pretty}
.cf-contact-form-4 .cf4-status strong{font-weight:800}
.cf-contact-form-4 .cf4-status.is-open strong{color:var(--success)}
.cf-contact-form-4 .cf4-dot{display:inline-block;width:10px;height:10px;margin-inline-end:.5em;border-radius:999px;background:var(--muted);vertical-align:.05em}
.cf-contact-form-4 .cf4-status.is-open .cf4-dot{background:var(--success)}
.cf-contact-form-4 .cf4-sep{color:var(--muted)}
.cf-contact-form-4 .cf4-name{order:1;margin:0;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;text-wrap:balance}
.cf-contact-form-4 .cf4-actions{order:2;display:grid;gap:12px}
.cf-contact-form-4 .cf4-address{order:3;display:flex;align-items:flex-start;gap:10px;margin:0;font-style:normal;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--ink)}
.cf-contact-form-4 .cf4-address svg{flex:none;margin-top:.2em;color:var(--accent)}
.cf-contact-form-4 .cf4-btn{display:flex;align-items:center;justify-content:center;gap:14px;width:100%;min-height:64px;padding:10px 24px;border-radius:var(--button-radius,var(--radius,12px));font-family:var(--button-font,var(--font-display));text-transform:var(--button-case,none);text-decoration:none;text-align:center;cursor:pointer;transition:transform .16s ease,box-shadow .16s ease,background .16s ease;-webkit-tap-highlight-color:transparent}
.cf-contact-form-4 .cf4-btn-icon{flex:none}
.cf-contact-form-4 .cf4-btn-text{display:flex;flex-direction:column;align-items:center;min-width:0}
.cf-contact-form-4 .cf4-btn-label{display:inline-flex;align-items:center;justify-content:center;gap:8px;font-size:clamp(1.125rem,1.55vw,1.375rem);font-weight:var(--button-weight,800);line-height:1.15}
.cf-contact-form-4 .cf4-btn-sub{margin-top:3px;font-family:var(--font-body);font-size:.9375rem;font-weight:600;line-height:1.3;font-variant-numeric:tabular-nums;text-transform:none;text-wrap:pretty}
.cf-contact-form-4 .cf4-call,.cf-contact-form-4 .cf4-submit{color:var(--button-ink,var(--cta-ink));text-shadow:var(--button-text-shadow,none);background:linear-gradient(oklch(from var(--button-bg,var(--cta)) calc(l + .04) c h),oklch(from var(--button-bg-2,var(--cta-2)) calc(l - .02) c h));box-shadow:inset 0 1px 0 oklch(from var(--button-bg,var(--cta)) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--button-bg,var(--cta)) calc(l - .16) c h),var(--button-shadow,0 1px 2px oklch(from var(--cf4-shadow) l c h / .3),0 8px 16px -6px oklch(from var(--cf4-shadow) l c h / .42))}
.cf-contact-form-4 .cf4-call:hover,.cf-contact-form-4 .cf4-call.is-hover,.cf-contact-form-4 .cf4-submit:not(:disabled):hover{background:linear-gradient(oklch(from var(--button-bg,var(--cta)) calc(l - .01) c h),oklch(from var(--button-bg-2,var(--cta-2)) calc(l - .07) c h));box-shadow:inset 0 1px 0 oklch(from var(--button-bg,var(--cta)) calc(l + .14) c h / .7),inset 0 -3px 0 oklch(from var(--button-bg,var(--cta)) calc(l - .16) c h),0 1px 2px oklch(from var(--cf4-shadow) l c h / .32),0 12px 20px -6px oklch(from var(--cf4-shadow) l c h / .5)}
.cf-contact-form-4 .cf4-call:active,.cf-contact-form-4 .cf4-call.is-active,.cf-contact-form-4 .cf4-submit:not(:disabled):active{transform:translateY(1px);background:linear-gradient(oklch(from var(--button-bg,var(--cta)) calc(l - .04) c h),oklch(from var(--button-bg-2,var(--cta-2)) calc(l - .08) c h));box-shadow:inset 0 2px 4px oklch(from var(--button-bg,var(--cta)) calc(l - .22) c h / .45),inset 0 -2px 0 oklch(from var(--button-bg,var(--cta)) calc(l - .16) c h),0 1px 1px oklch(from var(--cf4-shadow) l c h / .3)}
.cf-contact-form-4 .cf4-dir{color:var(--button-2-ink,var(--secondary-ink));background:var(--button-2-bg,var(--secondary));border:1px solid var(--button-2-border,transparent);box-shadow:var(--button-2-shadow,var(--shadow-sm))}
.cf-contact-form-4 .cf4-dir:hover{background:oklch(from var(--button-2-bg,var(--secondary)) calc(l - .04) c h)}
.cf-contact-form-4 .cf4-dir:active{transform:translateY(1px)}
.cf-contact-form-4 a:focus-visible,.cf-contact-form-4 button:focus-visible{outline:3px solid var(--field-focus,var(--accent));outline-offset:3px}
.cf-contact-form-4 .cf4-hours{min-width:0}
.cf-contact-form-4 .cf4-hours-title,.cf-contact-form-4 .cf4-form-title{margin:0;font-family:var(--font-display);font-weight:var(--display-weight,800);letter-spacing:-0.01em;text-transform:var(--display-case,none);font-size:clamp(1.3125rem,1.8vw,1.625rem);line-height:1.15;text-wrap:balance;color:var(--ink)}
.cf-contact-form-4 .cf4-hours-title{margin-bottom:16px}
.cf-contact-form-4 .cf4-today{margin-bottom:12px;padding:16px;border-radius:10px;background:color-mix(in oklch,var(--ink) 4%,var(--card))}
.cf-contact-form-4 .cf4-today-head{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 16px}
.cf-contact-form-4 .cf4-today-hours{font-size:1.0625rem;font-weight:800;line-height:1.4}
.cf-contact-form-4 .cf4-today-now{font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted);font-variant-numeric:tabular-nums}
.cf-contact-form-4 .cf4-track{position:relative;height:12px;margin-top:16px;border-radius:999px;background:color-mix(in oklch,var(--ink) 12%,var(--card))}
.cf-contact-form-4 .cf4-span{position:absolute;top:0;bottom:0;border-radius:999px;background:var(--accent-fill,var(--accent));transform-origin:left center;animation:cf4-grow .45s cubic-bezier(.2,.7,.2,1) both}
.cf-contact-form-4 .cf4-now{position:absolute;top:-6px;width:4px;height:24px;margin-left:-2px;border-radius:999px;background:var(--ink);outline:2px solid var(--card);animation:cf4-pop .3s ease .2s both}
.cf-contact-form-4 .cf4-ticks{display:flex;justify-content:space-between;margin-top:10px;font-size:.875rem;font-weight:800;line-height:1.2;color:var(--muted);font-variant-numeric:tabular-nums}
.cf-contact-form-4 .cf4-list{display:grid;margin:0}
.cf-contact-form-4 .cf4-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:12px;padding:12px 14px;border-radius:10px;border-top:1px solid transparent}
.cf-contact-form-4 .cf4-row + .cf4-row{border-top-color:oklch(from var(--ink) l c h / .1)}
.cf-contact-form-4 .cf4-row.is-today{background:color-mix(in oklch,var(--accent) 10%,var(--card));border-top-color:transparent}
.cf-contact-form-4 .cf4-row.is-today + .cf4-row{border-top-color:transparent}
.cf-contact-form-4 .cf4-row dt{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;min-width:0;margin:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:700;line-height:1.5}
.cf-contact-form-4 .cf4-row dd{margin:0;font-size:clamp(1.0625rem,1.25vw,1.125rem);font-weight:600;line-height:1.5;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
.cf-contact-form-4 .cf4-row dd.is-closed{color:var(--muted)}
.cf-contact-form-4 .cf4-row.is-today dd.is-closed{color:var(--ink)}
.cf-contact-form-4 .cf4-chip{display:inline-flex;align-items:center;min-height:24px;padding:4px 12px;border-radius:999px;background:var(--accent-fill,var(--accent));color:var(--accent-fill-ink,var(--card));font-size:.875rem;font-weight:800;line-height:1;animation:cf4-pop .3s ease both}
.cf-contact-form-4 .cf4-closure{margin:14px 0 0;padding:12px 14px;border-radius:10px;background:var(--warning-soft);color:var(--warning);font-size:.9375rem;font-weight:600;line-height:1.4;text-wrap:pretty}
.cf-contact-form-4 .cf4-closure svg,.cf-contact-form-4 .cf4-error svg{display:inline-block;vertical-align:-0.15em;margin-inline-end:.4em}
.cf-contact-form-4 .cf4-form{display:grid;align-items:start;gap:24px;margin-top:clamp(28px,4vw,40px);padding-top:clamp(28px,4vw,40px);border-top:1px solid oklch(from var(--ink) l c h / .14)}
.cf-contact-form-4 .cf4-form-lead{margin:12px 0 0;font-size:clamp(1.0625rem,1.25vw,1.125rem);line-height:1.5;color:var(--muted);text-wrap:pretty}
.cf-contact-form-4 .cf4-fields{display:grid;gap:16px;min-width:0;margin:0;padding:0;border:0}
.cf-contact-form-4 .cf4-pair{display:grid;gap:16px}
.cf-contact-form-4 .cf4-field{display:grid;gap:8px;min-width:0}
.cf-contact-form-4 .cf4-label{font-size:1rem;font-weight:700;line-height:1.3;color:var(--label-ink,var(--ink))}
.cf-contact-form-4 .cf4-input{display:block;width:100%;min-height:56px;padding:0 16px;border:1px solid var(--field-border,color-mix(in oklch,var(--ink) 22%,transparent));border-radius:var(--field-radius,var(--radius,12px));background:var(--field);color:var(--field-ink);font-family:var(--font-body);font-size:1.0625rem;line-height:1.4;appearance:none;transition:border-color .16s ease,box-shadow .16s ease}
.cf-contact-form-4 textarea.cf4-input{min-height:128px;padding:14px 16px;line-height:1.5;resize:vertical}
.cf-contact-form-4 .cf4-input::placeholder{color:color-mix(in oklch,var(--field-ink) 65%,var(--field));opacity:1}
.cf-contact-form-4 .cf4-input:focus{outline:none;border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--accent)) l c h / .35)}
.cf-contact-form-4 .cf4-input[aria-invalid='true']{border-color:var(--danger)}
.cf-contact-form-4 .cf4-input[aria-invalid='true']:focus{box-shadow:0 0 0 3px oklch(from var(--danger) l c h / .3)}
.cf-contact-form-4 .cf4-input:disabled{background:color-mix(in oklch,var(--ink) 5%,var(--field));cursor:not-allowed}
.cf-contact-form-4 .cf4-error{margin:0;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--danger);text-wrap:pretty;animation:cf4-rise .3s cubic-bezier(.2,.7,.2,1) both}
.cf-contact-form-4 .cf4-send{display:grid;justify-items:stretch;gap:10px;margin-top:4px}
.cf-contact-form-4 .cf4-submit{border:0;padding:10px 28px}
.cf-contact-form-4 .cf4-submit:disabled{background:var(--button-2-bg,var(--secondary));color:var(--button-2-ink,var(--secondary-ink));text-shadow:none;box-shadow:none;cursor:not-allowed}
.cf-contact-form-4 .cf4-submit[aria-busy='true']{cursor:progress}
.cf-contact-form-4 .cf4-note{margin:0;font-size:.9375rem;font-weight:500;line-height:1.4;color:var(--muted);text-wrap:pretty}
.cf-contact-form-4 .cf4-spin{animation:cf4-spin .8s linear infinite}
.cf-contact-form-4 .cf4-reveal{animation:cf4-rise .45s cubic-bezier(.2,.7,.2,1) both}
@media (min-width:560px){
.cf-contact-form-4 .cf4-pair{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
.cf-contact-form-4 .cf4-send{justify-items:start}
.cf-contact-form-4 .cf4-submit{width:auto;min-width:280px}
}
@media (max-width:640px){
.cf-contact-form-4 .cf4-photo{height:auto;aspect-ratio:4 / 3}
}
@media (min-width:860px){
.cf-contact-form-4 .cf4-visit,.cf-contact-form-4 .cf4-form{grid-template-columns:minmax(0,1fr) minmax(0,1.08fr);gap:clamp(32px,5vw,64px)}
.cf-contact-form-4 .cf4-address{order:2}
.cf-contact-form-4 .cf4-actions{order:3;margin-top:8px}
}
@keyframes cf4-rise{from{opacity:.82;transform:translateY(8px)}}
@keyframes cf4-grow{from{opacity:.82;transform:scaleX(.85)}}
@keyframes cf4-pop{from{transform:scale(.9)}}
@keyframes cf4-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){
.cf-contact-form-4 .cf4-reveal,.cf-contact-form-4 .cf4-span,.cf-contact-form-4 .cf4-now,.cf-contact-form-4 .cf4-chip,.cf-contact-form-4 .cf4-error,.cf-contact-form-4 .cf4-spin{animation:none}
.cf-contact-form-4 .cf4-btn,.cf-contact-form-4 .cf4-input{transition:none}
}
`;
pieces/forms/contact-form-4/specimen.tsx 41 lines
import __studioImage9d6b4e61 from "../assets/2d10540d68d2cfff.webp";
import * as React from 'react';
import { ContactForm4, type ContactForm4State } from '../contact-form-4';
import { slot } from '../../slots';
export const states = ['default', 'hover', 'active', 'disabled', 'error'];
export default function ContactForm4Specimen({ state = 'default' }: { state?: ContactForm4State }) {
return (
<ContactForm4
state={state}
headline='Come in hungry.'
headlineAccent='We’ll have the ovens on.'
lead='Fresh loaves from 7am, coffee all morning and a counter full of whatever just came out of the oven. Here’s how to find us.'
aside='(Fair warning: you’ll smell the bread before you see the sign.)'
sceneImage={slot(
'scene',
__studioImage9d6b4e61
)}
sceneAlt='Marigold Bakery’s yellow shopfront on Linden Street in the early morning'
name='Marigold Bakery'
address={['48 Linden Street', 'Riverside Heights']}
phone='(555) 014-2260'
callLabel='Call the bakery'
hoursHeading='Fresh from the oven six days a week'
hours={[
{ label: 'Monday', days: [1], closed: true },
{ label: 'Tuesday – Friday', days: [2, 3, 4, 5], opens: '07:00', closes: '15:00' },
{ label: 'Saturday', days: [6], opens: '07:00', closes: '14:00' },
{ label: 'Sunday', days: [0], opens: '08:00', closes: '13:00' },
]}
closure='Closed Thursday 26 November for Thanksgiving. Back Friday at 7am.'
formHeading='Ordering a cake? Ask before you come in.'
formLead='Tell us the date and how many people. We’ll reply by email with what we can bake.'
submitLabel='Send my question'
submitNote='Goes straight to the bakery'
privacy='We only use your email to reply to you.'
copy={{ messagePlaceholder: 'A chocolate cake for 12 people on Saturday?' }}
/>
);
}
| Name | Type | Details |
|---|---|---|
headline OptionalContactForm4 |
React.ReactNode |
|
headlineAccent OptionalContactForm4 |
React.ReactNode |
|
lead OptionalContactForm4 |
React.ReactNode |
|
aside OptionalContactForm4 |
React.ReactNode |
|
sceneImage OptionalContactForm4 |
string |
|
sceneAlt OptionalContactForm4 |
string |
|
sceneFocus OptionalContactForm4 |
string |
|
name OptionalContactForm4 |
string |
|
address OptionalContactForm4 |
string[] |
|
phone OptionalContactForm4 |
string |
|
phoneHref OptionalContactForm4 |
string |
|
callLabel OptionalContactForm4 |
string |
|
directionsHref OptionalContactForm4 |
string |
|
directionsLabel OptionalContactForm4 |
string |
|
directionsNote OptionalContactForm4 |
string |
|
hoursHeading OptionalContactForm4 |
string |
|
hours OptionalContactForm4 |
ContactForm4Hours[] |
|
closure OptionalContactForm4 |
string |
|
formHeading OptionalContactForm4 |
string |
|
formLead OptionalContactForm4 |
string |
|
submitLabel OptionalContactForm4 |
string |
|
submitNote OptionalContactForm4 |
string |
|
privacy OptionalContactForm4 |
string |
|
copy OptionalContactForm4 |
Partial<ContactForm4Copy> |
|
onSubmit OptionalContactForm4 |
(values: ContactForm4Values) => void | Promise<unknown> |
|
state OptionalContactForm4 |
ContactForm4State |
|
className OptionalContactForm4 |
string |
|
id OptionalContactForm4 |
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.
scene- A wide atmosphere photo behind or beside the copy.
-
2d10540d68d2cfff.webp
image/webp · 163 KB