Skip to content
New

Newsletter, inline

beta

A 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

One useful email a month

Pricing, getting paid and running a small studio: what we learn from twelve thousand of them.

No spam, no selling your address. Unsubscribe in one click.

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.

Installation

Terminal
npx rasengan-ui add newsletter-inline

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):

app/_routes/index.page.tsx
import { NewsletterInline } from "@/components/blocks/newsletter-inline";
import { home } from "@/content/home";
 
export default function Home() {
  return <NewsletterInline content={home.newsletter} />;
}
content/home.ts
import { example, type NewsletterInlineContent } from "@/components/blocks/newsletter-inline";
 
export const home = {
  newsletter: { ...example, form: { ...example.form, action: "https://buttondown.com/api/emails/embed-subscribe/senbon" } } satisfies NewsletterInlineContent,
};

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.

<NewsletterInline content={home.newsletter} onSubmit={(email) => subscribe(email)} />

Content

FieldTypeLimitsGuidance
titlestring6–60 charsWhat they get, and how often: 'One useful email a month'.
sublineoptionalstring≤ 160 chars
formobject
form.actionstringWhere the form posts: your newsletter provider's subscribe URL, or your own endpoint.
form.methodoptional"post" | "get"default "post"
form.nameoptionalstring1–32 chars, default "email"The email field's name, as your provider expects it.
form.labelstring1–32 chars'Email address'
form.placeholderoptionalstring≤ 48 chars
form.submitstring1–24 chars'Subscribe'
form.newTaboptionalbooleandefault falseOpen the provider's confirmation page in a new tab.
noteoptionalstring≤ 140 charsUnder the field: how often, and that unsubscribing is one click.
labelsobjectShown only when needed.
labels.invalidstring1–60 charsUnder a wrong address: 'Enter an email address like name@example.com'.
labels.sentstring1–120 charsWhen the page handles the address itself (`onSubmit`): 'Thanks! Check your inbox to confirm.'

Props

PropNotes
contentNewsletterInlineContent; the example when left out
onSubmit(email) => void | Promise<void>: take the address in code instead of posting the form
idthe section's id, for anchor links; "newsletter" by default
headingLevel1, 2 or 3: the heading's tag; 2 by default
classNameon 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.