# Mobile paywall

A full screen phone paywall that answers the money questions: what is charged, when, and how to stop it.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Mobile paywall. On a phone: the yearly plan with its trial timeline, the monthly plan without one, restore, and a purchase. Preview: https://chatcn.dev/preview/mobile-paywall-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/mobile-paywall
```

## Usage

```tsx
import { MobilePaywall } from "@/components/ui/chatcn/pro/mobile-paywall"

<MobilePaywall
  title="Do more with Pro"
  subtitle="The best models, more room, and no daily caps."
  features={[{ icon: <BrainIcon />, title: "Claude Opus 5.5 and GPT-6.1 Sol", detail: "…" }, …]}
  plans={[
    { id: "yearly", label: "Yearly", price: "$119.99", period: "year", perMonth: "$10.00 a month", note: "Save 33%", trialDays: 7 },
    { id: "monthly", label: "Monthly", price: "$14.99", period: "month" },
  ]}
  onPurchase={(plan) => store.purchase(plan)}   // throw when it fails or is cancelled
  onRestore={() => store.restore()}             // true when something was restored
  onClose={dismiss}
  onDone={enterApp}
  termsHref="/terms"
  privacyHref="/privacy"
/>
```

Fills its parent, so give it the screen (`h-dvh`) or a sheet. The close button is there from the first frame; a paywall that hides it costs more trust than it earns. Plans are big radio cards with the full price per period and, for long plans, the monthly figure beside it. A plan with a free trial shows a short timeline: what unlocks today, the day a reminder is sent, and the day the card is charged with the amount. The line under the button restates the renewal terms for the plan picked, as app stores require. Restore purchase answers in words: restored, nothing to restore, or the store could not be reached. A purchase turns into the welcome in place with focus on its button. Prices come from your store; pass them already formatted for the reader's region. Safe area insets are read from `--chatcn-safe-top` and `--chatcn-safe-bottom` when set.

## Examples

### States

Example: States. The monthly plan with no trial, and a purchase the store declined with nothing charged. Preview: https://chatcn.dev/preview/mobile-paywall-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `title`, `subtitle`, `mark` | `ReactNode` | The heading, a line under it, your app icon |
| `features` | `PaywallFeature[]` | `{ title, detail?, icon? }` |
| `plans` | `PaywallPlan[]` | `{ id, label, price, period, perMonth?, note?, trialDays? }` |
| `value`, `defaultValue`, `onValueChange` | `string` | The plan picked |
| `onPurchase` | `(plan) => Promise<void>` | Throw when it fails or is cancelled; nothing is shown as charged |
| `onRestore` | `() => Promise<boolean>` | Shows Restore purchase |
| `onClose`, `onDone` |  | Dismiss, and carry on after buying |
| `termsHref`, `privacyHref` | `string` | Links in the footer |
| `now` | `Date` | Pins the trial dates |
| `labels` | `Partial<MobilePaywallLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Arrow keys | Move between plans |
| Enter | Buy, on the main button |

## Accessibility

- Plans are native radio buttons in a labelled group.
- The main button is described by the renewal terms, so they are read with it.
- A failed purchase is an alert; restore results and the welcome are status messages.

## Motion

The trial timeline rises in when a trial plan is picked, and the welcome check rises in once. Nothing moves under reduced motion.

Source: https://chatcn.dev/docs/components/mobile-paywall