ComponentsForms & inputs

Email capture

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.

components/email-capture.tsxtheme · material · accent · density · font

One letter every other Sunday. Unsubscribe in one click.

I have read the privacy notice.

Installation

$ pnpm add @vamos-ui/react

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.

Enter an email address like name@example.com.

Thanks — check your inbox to confirm.

API

EmailCapture

PropTypeDefault
layout
One row once there is room, or the button under the field.
"inline" | "stacked""inline"
action
A server action, or a URL: plain POST without JS, fetch with Accept: application/json after hydration ({ status: "success" | "invalid" | "error" }).
SiteFormAction | string—
onSubmit
Client handler instead of action; a rejection shows the error state.
(email, data: FormData) => void | Promise<void>—
label / hideLabel
The field label; hideLabel keeps it for screen readers only.
ReactNode / boolean"Email address"
placeholder / hint / submitLabel
Placeholder, small print under the field, button text.
string / ReactNode / string—
privacyLink
Privacy notice link (KVKK requires one); version is posted as _notice.
{ href; label?; version? }—
privacyCheckbox
A required, never pre-checked confirmation (posted as privacy=on).
boolean—
successMessage
Replaces the form after success; focus moves to it.
ReactNode—
name / size
Input name and control height.
string / "md" | "lg""email" / "md"
initialState
Render a given state.
SiteFormState—
labels
Dictionary namespace "emailCapture" (en, tr, de, fr, es, ar built in).
Partial<EmailCaptureLabels>—