Newsletter
Newsletter signup band; a plain HTML form that works without JavaScript.
Preview
With onSubmit, the form morphs into a success message; a live region announces the result. With reduced motion turned on, it renders the plain layout.
One email a month
New sections and templates, nothing else. Sample copy.
Unsubscribe anytime.
One email a month
New sections and templates, nothing else. Sample copy.
Unsubscribe anytime.
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { Newsletter } from "@/components/custom/newsletter";
<Newsletter title="One email a month" action="/api/subscribe" note="Unsubscribe anytime." />import { NewsletterMotion } from "@/components/custom/newsletter/newsletter-motion";
<NewsletterMotion title="One email a month" action="/api/subscribe" onSubmit={subscribe} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | Heading (h2). |
| action* (required) | string | – | Where the form posts. |
| method | "post" | "get" | "post" | Form method. |
| inputLabel | string | "Email address" | Field label (visually hidden). |
| buttonLabel | string | "Subscribe" | Button text. |
| note | string | – | Small print. |
| ...props | React.ComponentProps<"section"> | – | Any other section attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | Heading (h2). |
| action* (required) | string | – | Where the form posts. |
| method | "post" | "get" | "post" | Form method. |
| inputLabel | string | "Email address" | Field label (visually hidden). |
| buttonLabel | string | "Subscribe" | Button text. |
| note | string | – | Small print. |
| ...props | React.ComponentProps<"section"> | – | Any other section attribute (id, aria-*, data-*, ref) goes to the root element. |
| onSubmit | (email: string) => Promise<void> | – | Handle the signup yourself; shows sending, success and error states. |
| successMessage | string | "Thanks, you're subscribed." | Shown after onSubmit resolves. |
Accessibility
- A labelled email field with autocomplete; the form works without JavaScript.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.