Newsletter, inline
betaA band asking for an email address: the promise beside a field and a button, posting to your newsletter provider.
npx rasengan-ui add newsletter-inline
- Use it
- A product or a studio with a newsletter worth reading, above the footer or between sections.
- Avoid it
- No provider or endpoint to post to yet.
- Pairs with
- Footer, columnsCall to action, banner
Installation
It installs into components/blocks/newsletter-inline/, with what it uses (Button, Field, Input) and lib/blocks.ts.
Usage
Without content, the block shows its example. Pass your own, typed by the block's schema, from a content file (here, the example with one field changed):
The form posts the address to form.action, your newsletter provider's subscribe URL (most give one for embedded forms) or your own endpoint, under the field name form.name. Set form.newTab to open the provider's confirmation page in a new tab. To call the provider yourself, pass onSubmit: the block takes the address, waits for your function and shows labels.sent.
Content
| Field | Type | Limits | Guidance |
|---|---|---|---|
title | string | 6–60 chars | What they get, and how often: 'One useful email a month'. |
sublineoptional | string | ≤ 160 chars | |
form | object | ||
form.action | string | Where the form posts: your newsletter provider's subscribe URL, or your own endpoint. | |
form.methodoptional | "post" | "get" | default "post" | |
form.nameoptional | string | 1–32 chars, default "email" | The email field's name, as your provider expects it. |
form.label | string | 1–32 chars | 'Email address' |
form.placeholderoptional | string | ≤ 48 chars | |
form.submit | string | 1–24 chars | 'Subscribe' |
form.newTaboptional | boolean | default false | Open the provider's confirmation page in a new tab. |
noteoptional | string | ≤ 140 chars | Under the field: how often, and that unsubscribing is one click. |
labels | object | Shown only when needed. | |
labels.invalid | string | 1–60 chars | Under a wrong address: 'Enter an email address like name@example.com'. |
labels.sent | string | 1–120 chars | When the page handles the address itself (`onSubmit`): 'Thanks! Check your inbox to confirm.' |
Props
| Prop | Notes |
|---|---|
content | NewsletterInlineContent; the example when left out |
onSubmit | (email) => void | Promise<void>: take the address in code instead of posting the form |
id | the section's id, for anchor links; "newsletter" by default |
headingLevel | 1, 2 or 3: the heading's tag; 2 by default |
className | on the <section>, for spacing |
Accessibility
- The field has its visible label; a malformed address says so under it and is not sent.
- After
onSubmit, a status line says what happens next.