Skip to content
All blocks

[14] Marketing

Newsletter Signup

An email field and a button in a card, replaced by a success message once the form is sent.

1280px

Copy the code

One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide. It passes an onSubmit handler, so in the Next.js App Router add "use client" at the top of its file.

newsletter.tsx

import { useState } from "react";
import { Alert, Button, Card, Col, Container, Input, Row, Section, Text, Title } from "@vaneui/ui";
export function Newsletter() {
const [email, setEmail] = useState("");
// Once the form is sent, the success message replaces it
const [sent, setSent] = useState(false);
return (
<Section>
<Container>
<Card wFull className="max-w-2xl">
<Col xs>
<Title tag="h2">Get the Acme newsletter</Title>
<Text secondary>One email a month with new features, customer stories and tips. Unsubscribe any time.</Text>
</Col>
{sent ? (
<Alert success polite>
<Text>Almost done. We sent a link to {email}, open it to confirm.</Text>
</Alert>
) : (
<Row tag="form" mobileStack itemsStretch onSubmit={(e) => { e.preventDefault(); setSent(true); }}>
<Input type="email" name="email" aria-label="Email" placeholder="you@company.com" autoComplete="email" required
value={email} onChange={(e) => setEmail(e.target.value)} />
<Button type="submit" filled noShrink mobileWFull>Subscribe</Button>
</Row>
)}
</Card>
</Container>
</Section>
);
}

How it adapts

  • 768px and up: the field and the button share one row, in a card at most 672px wide.
  • Below 768px: the button moves under the field and fills the width.
  • The success message is a polite live region, so screen readers announce it without interrupting.

How these props work is in responsive page sections without breakpoint classes.

Adapt it with your coding agent

Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.

$ claude mcp add vaneui -- npx -y @vaneui/mcp

Setup for other editors is in the AI assistants guide.