A compact email signup for a newsletter, a waitlist or the end of an article: field and button in one row (or stacked), validation tied to the input, success and error states, and the privacy link or KVKK checkbox. It speaks the ContactForm contract — a URL or server action, honeypot and time trap, privacy / _notice / _form fields — so one server check covers both. For a full-width signup section use the Cta block's newsletter variant.
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { EmailCapture } from "@vamos-ui/react";
<EmailCapture action="/api/subscribe" hint="One email a month." privacyLink={{ href: "/privacy" }} />
// Server side (same check as ContactForm)
const v = validateContactForm([{ name: "email", required: true }], data, { privacyCheckbox: true });Validates on submit, then re-validates on the next submit; errors are tied to the input with aria-describedby and focus moves to the field.
Without JS a URL action is a normal POST; a server can redirect back with ?vb_sent=<form id> to show the success state.
Consent to marketing is the signup itself here; keep any separate offers out of it (ContactForm has marketingConsent for that).
Examples
Stacked in a card, KVKK checkbox
privacyCheckbox adds a required, never pre-checked box; version is posted as _notice so the server can record which wording was shown.
Get the next issue
New essays on small-scale gardening, once a month.
Server action
action takes a useActionState function (prev, FormData) → SiteFormState. Invalid results map back onto the field.
States
initialState renders invalid, error and success — for docs, tests or a server-rendered result.
API
EmailCapture
| Prop | Type | Default |
|---|---|---|
layoutOne row once there is room, or the button under the field. | "inline" | "stacked" | "inline" |
actionA server action, or a URL: plain POST without JS, fetch with Accept: application/json after hydration ({ status: "success" | "invalid" | "error" }). | SiteFormAction | string | — |
onSubmitClient handler instead of action; a rejection shows the error state. | (email, data: FormData) => void | Promise<void> | — |
label / hideLabelThe field label; hideLabel keeps it for screen readers only. | ReactNode / boolean | "Email address" |
placeholder / hint / submitLabelPlaceholder, small print under the field, button text. | string / ReactNode / string | — |
privacyLinkPrivacy notice link (KVKK requires one); version is posted as _notice. | { href; label?; version? } | — |
privacyCheckboxA required, never pre-checked confirmation (posted as privacy=on). | boolean | — |
successMessageReplaces the form after success; focus moves to it. | ReactNode | — |
name / sizeInput name and control height. | string / "md" | "lg" | "email" / "md" |
initialStateRender a given state. | SiteFormState | — |
labelsDictionary namespace "emailCapture" (en, tr, de, fr, es, ar built in). | Partial<EmailCaptureLabels> | — |