Marketing sectionsNewsletterCentered
Searchastronomic.dev# NewsletterCentered
To ask for email signups in a centered block, such as near the end of a page or on the band.
Interactive: inline script.
## Usage
```astro
import NewsletterCentered from "@astronomic-dev/ui/components/NewsletterCentered.astro";
```
## Examples
### Centered
The header centered, then the form under it at a reading width (at most 28rem), the field and button in one row where they fit, with its label shown. It posts to # here. For the heading beside the form, use NewsletterInline.
```astro
---
import NewsletterCentered from "@astronomic-dev/ui/components/NewsletterCentered.astro";
---
<div class="mx-auto max-w-6xl px-6 py-16">
<NewsletterCentered heading="New work, once a month" text="A short email when there is something worth showing. No news roundups." form={{ action: "#" }}>
<p slot="note" class="m-0">No spam. Unsubscribe at any time.</p>
</NewsletterCentered>
</div>
```
### On the band
tone="band": the section takes the band's background, an edge and padding, and the recipe gives the heading, the text, the form's labels, the button and every focus ring the band's colors. A band shows when a preset sets --ui-band; without one, it is the page, with the edge.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import NewsletterCentered from "@astronomic-dev/ui/components/NewsletterCentered.astro";
---
<div class="mx-auto max-w-6xl px-6 py-16">
<NewsletterCentered tone="band" heading="New work, once a month" text="A short email when there is something worth showing. No news roundups." form={{ action: "#" }}>
<Badge slot="eyebrow">Newsletter</Badge>
<p slot="note" class="m-0">No spam. Unsubscribe at any time.</p>
</NewsletterCentered>
</div>
```
## Props
### NewsletterCentered
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | The section heading, in the title role in display type. Without it there is no section and no header: a plain <div> holds only the body. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside, as in "Built for *the long run*". Any other asterisks show as typed. Off by default, so the heading shows as typed. How the <em> looks is the theme's. |
| `mark` | `string` | None | A short mark after the heading, such as "(12)" or "©2026", in small muted type. It sits beside the heading, outside it, so the heading's name stays plain. Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "12 projects": the mark is then hidden from screen readers and this is read in its place. Without it, the mark is read as written. |
| `text` | `string` | None | One or two sentences under the heading, in the lead role, muted. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. Benefit titles, if any, sit one level under it. |
| `tone` | `"page" \| "band"` | `"page"` | The surface. page: on the page. band: the band (surface-band, the band when a preset sets --ui-band, else the page) with its focus ring, an edge and padding, wider once the section is 48rem across. The padding sits on a box inside the section, so a class you pass (padding too) goes to the section, around that box. The recipes' two columns then start when the space inside the padding is 48rem: on the band that is 48rem plus twice the wide padding. Give the form the same tone. |
| `class` | `string` | None | More classes for the root (the <section>, or the <div> without a heading), merged with cn(), so yours win on conflicts. The root is a named size container (inline-size containment): in a shrink-to-fit parent (inline-flex, a float, fit-content) it collapses, so give it a width there. |
| `form` | `SignupFormOptions` | None | Required. The form's settings: its action (required) and any SignupForm prop but tone and class (SignupFormOptions), spread onto the form, such as { action: "https://buttondown.com/api/emails/embed-subscribe/<user>", hiddenFields: [{ name: "embed", value: "1" }] }. A plain post is the safe default; see SignupForm for each provider's row. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
| `note` | Under the form, small and muted: the privacy line. Passed to the SignupForm. |
Any other attribute goes on the <section>, or on the <div> without a heading.
## Accessibility
- With a heading, renders a <section> named by it, so it is a region landmark. The heading id is unique on the page.
- Without a heading, renders a plain <div>. Put your own heading above it.
- With tone="band", the section takes the band's background, text color and focus ring. A shell cannot pass the tone into its slot, so give the SignupForm tone="band" too (the recipes do it for you).
- The header comes before the form, in the page and on screen.
- Each field has a visible label, or, with labelHidden, a label kept for screen readers only, when the heading beside the form already says what it is for. A placeholder is only a hint, never the label.
- The email field is type=email with autocomplete email and no spellcheck, and is required and marked so; the optional name field has autocomplete name.
- The note slot holds the privacy line (how often you write, how to unsubscribe), under the form, small and muted.
- With no script, or before it loads, the form posts to its action and the browser checks the email itself. Buttondown, Mailchimp and Formspree each show their own page after the post, so a signup works with no JavaScript.
- With enhance="fetch", a bad email gets its error text under the field, aria-invalid and the error id in aria-describedby, and focus moves to it. The FormStatus under the button says sending, then success or the error. Use it only with an endpoint that answers JSON (Formspree); Buttondown and Mailchimp must use a plain post.
NewsletterCentered
FreeTo ask for email signups in a centered block, such as near the end of a page or on the band.
- File
- NewsletterCentered.astro
- Group
- Marketing sections
- Kind
- Interactive: inline script
- Examples
- 2
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Centered
The header centered, then the form under it at a reading width (at most 28rem), the field and button in one row where they fit, with its label shown. It posts to # here. For the heading beside the form, use NewsletterInline.
On the band
tone="band": the section takes the band's background, an edge and padding, and the recipe gives the heading, the text, the form's labels, the button and every focus ring the band's colors. A band shows when a preset sets --ui-band; without one, it is the page, with the edge.
Minimal · Light