Publishing sectionsPaywall
Searchastronomic.dev# Paywall
Where a members-only post stops: the part readers may see, then a card that asks them to subscribe or sign in.
Static: no JavaScript.
## Usage
```astro
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
```
## Examples
### A locked post
The preview your data layer rendered (here a Prose with two paragraphs and a heading), at full contrast; three short ghost lines fading out after it; then the members card on the quiet fill: a lock mark, the heading, a line, the subscribe Button and the sign-in link.
```astro
---
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall
heading="The rest is for members"
text="Members read every part of Launch notes, the monthly long read and the full archive. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
>
<!-- The preview, already rendered by your data layer: plain paragraphs and headings, no links. The locked text is never in the page. -->
<Prose>
<div>
<p>Every Astronomic launch starts two weeks out, with one page of dates on the studio wall. Nothing on it is a guess: each date is a check we have run on every site since the first one.</p>
<h2 id="preview-first-week">The first week</h2>
<p>Day one is copy. Not the design, not the build: the words on every page, read aloud by someone who did not write them. The rest of the week follows from what that reading finds.</p>
</div>
</Prose>
</Paywall>
</div>
```
### No preview
With nothing in the default slot (or only an empty wrapper), the card alone, with no fade.
```astro
---
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<!-- A post with no preview: the card alone, with no fade. -->
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall
heading="This post is for members"
text="Members read every post in the Astronomic journal. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
/>
</div>
```
### Your own sign-in
A kit Form with an email Field in the sign-in slot, in place of the link: built from kit parts on the page, with no heading of its own. It stacks under the Button, after a quiet rule, in a centered block up to 24rem wide; the field and its Button share a row once the card is wide enough (a paywall container query), and stack, the Button full width, below that. Its Button is secondary (submitVariant), so Subscribe stays the main action.
```astro
---
import Field from "@astronomic-dev/ui/components/Field.astro";
import Form from "@astronomic-dev/ui/components/Form.astro";
import Input from "@astronomic-dev/ui/components/Input.astro";
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall heading="The rest is for members" text="Members read every post. From $5 a month." action={{ label: "Subscribe", href: "#subscribe" }}>
<Prose>
<div>
<p>Every Astronomic launch starts two weeks out, with one page of dates on the studio wall.</p>
</div>
</Prose>
<!-- Your own sign-in control, built from kit parts on the page: here an email link form. Its Button is secondary, so Subscribe stays the main action. -->
<Form slot="sign-in" action="#" submitLabel="Email me a link" submitVariant="secondary" fieldsClass="@sm/paywall:grid-cols-[minmax(0,1fr)_auto] @sm/paywall:items-end" buttonClass="w-full @sm/paywall:w-auto">
<Field label="Already a member? Your email" for="paywall-sign-in-email">
<Input id="paywall-sign-in-email" name="email" type="email" autocomplete="email" spellcheck="false" required />
</Field>
</Form>
</Paywall>
</div>
```
### In a narrow column
In a 20rem column the Button and the sign-in link wrap to two lines and stay centered.
```astro
---
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<!-- A 20rem column: the Button and the sign-in link wrap to two lines and stay centered. -->
<div class="px-6 py-12">
<div class="w-80 max-w-full">
<Paywall
heading="The rest is for members"
text="Members read every post. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
>
<Prose>
<div>
<p>Day one is copy: the words on every page, read aloud by someone who did not write them.</p>
</div>
</Prose>
</Paywall>
</div>
</div>
```
## Props
### Paywall
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | Required. The card's heading, such as "The rest is for members". |
| `text` | `string` | None | One line under it, such as "Members read every part of the series. From $5 a month." |
| `action` | `Pick<NavAction, "label" \| "href">` | None | Required. The subscribe or upgrade link: { label, href }. Always a primary Button at the default size. |
| `signIn` | `{ label: string; href: string }` | None | A sign-in link after the Button, such as { label: "Already a member? Sign in", href }. The sign-in slot wins over it. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The card's heading element. h2 keeps the outline flat after the preview's own h2s. |
| `class` | `string` | None | More classes for the root <div>, merged with cn(). The root is a named size container (paywall). |
| Slot | Description |
| --- | --- |
| `default` | The preview, already rendered: what readers may see before the card (for example your data layer's preview inside a Prose). A slot with no text counts as none: no preview box and no fade. The check strips the tags and looks for text, so a preview of only an image counts as empty: give it a line of text, or leave the slot out. |
| `sign-in` | Your own sign-in control in place of the signIn link (a member plugin's button or form). Build it from kit parts on the page (Field, Input, Button, or Form with its status on its own line), so labels, the 44px control height, the focus ring and wrapping come with them. It stacks under the Button, after a quiet rule, in a centered block up to 24rem wide, its content start-aligned; lay it out by the card's width with @sm/paywall: classes. Keep the subscribe Button the main action: a Form here takes submitVariant="secondary". It sits after the Button in the Tab order and may not add a heading. |
Any other attribute goes on the root <div>.
## Accessibility
- The card is a region named by its heading.
- The fade is decoration, hidden from screen readers; the preview keeps full contrast (it is never masked or dimmed).
- The lock mark is decoration.
- The sign-in link has a 44px hit area on touch screens.
- The card's text, Button and focus ring are the page's, on the quiet fill (surface-2): the text reads at 4.5:1 and the ring at 3:1 there in every kit preset, light and dark.
- This part shows only what you pass it. It never hides text: keep locked text out of the page in your data layer.
Paywall
ProWhere a members-only post stops: the part readers may see, then a card that asks them to subscribe or sign in.
- File
- Paywall.astro
- Group
- Publishing sections
- Kind
- Static: no JavaScript
- Examples
- 4
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
A locked post
The preview your data layer rendered (here a Prose with two paragraphs and a heading), at full contrast; three short ghost lines fading out after it; then the members card on the quiet fill: a lock mark, the heading, a line, the subscribe Button and the sign-in link.
This preview did not load.
examples/paywall/main.astro
---
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall
heading="The rest is for members"
text="Members read every part of Launch notes, the monthly long read and the full archive. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
>
<!-- The preview, already rendered by your data layer: plain paragraphs and headings, no links. The locked text is never in the page. -->
<Prose>
<div>
<p>Every Astronomic launch starts two weeks out, with one page of dates on the studio wall. Nothing on it is a guess: each date is a check we have run on every site since the first one.</p>
<h2 id="preview-first-week">The first week</h2>
<p>Day one is copy. Not the design, not the build: the words on every page, read aloud by someone who did not write them. The rest of the week follows from what that reading finds.</p>
</div>
</Prose>
</Paywall>
</div>No preview
With nothing in the default slot (or only an empty wrapper), the card alone, with no fade.
This preview did not load.
examples/paywall/no-preview.astro
---
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<!-- A post with no preview: the card alone, with no fade. -->
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall
heading="This post is for members"
text="Members read every post in the Astronomic journal. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
/>
</div>Your own sign-in
A kit Form with an email Field in the sign-in slot, in place of the link: built from kit parts on the page, with no heading of its own. It stacks under the Button, after a quiet rule, in a centered block up to 24rem wide; the field and its Button share a row once the card is wide enough (a paywall container query), and stack, the Button full width, below that. Its Button is secondary (submitVariant), so Subscribe stays the main action.
This preview did not load.
examples/paywall/sign-in-slot.astro
---
import Field from "@astronomic-dev/ui/components/Field.astro";
import Form from "@astronomic-dev/ui/components/Form.astro";
import Input from "@astronomic-dev/ui/components/Input.astro";
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<div class="mx-auto max-w-2xl px-6 py-12">
<Paywall heading="The rest is for members" text="Members read every post. From $5 a month." action={{ label: "Subscribe", href: "#subscribe" }}>
<Prose>
<div>
<p>Every Astronomic launch starts two weeks out, with one page of dates on the studio wall.</p>
</div>
</Prose>
<!-- Your own sign-in control, built from kit parts on the page: here an email link form. Its Button is secondary, so Subscribe stays the main action. -->
<Form slot="sign-in" action="#" submitLabel="Email me a link" submitVariant="secondary" fieldsClass="@sm/paywall:grid-cols-[minmax(0,1fr)_auto] @sm/paywall:items-end" buttonClass="w-full @sm/paywall:w-auto">
<Field label="Already a member? Your email" for="paywall-sign-in-email">
<Input id="paywall-sign-in-email" name="email" type="email" autocomplete="email" spellcheck="false" required />
</Field>
</Form>
</Paywall>
</div>In a narrow column
In a 20rem column the Button and the sign-in link wrap to two lines and stay centered.
This preview did not load.
examples/paywall/narrow.astro
---
import Prose from "@astronomic-dev/ui/components/Prose.astro";
import Paywall from "@astronomic/ui-pro/components/Paywall.astro";
---
<!-- A 20rem column: the Button and the sign-in link wrap to two lines and stay centered. -->
<div class="px-6 py-12">
<div class="w-80 max-w-full">
<Paywall
heading="The rest is for members"
text="Members read every post. From $5 a month."
action={{ label: "Subscribe", href: "#subscribe" }}
signIn={{ label: "Already a member? Sign in", href: "#sign-in" }}
>
<Prose>
<div>
<p>Day one is copy: the words on every page, read aloud by someone who did not write them.</p>
</div>
</Prose>
</Paywall>
</div>
</div>