# Cancel flow

Cancelling without the maze: one optional reason, at most one fitting offer, and a confirmation that says what is kept and what goes.

> 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: Cancel flow. One optional question, at most one offer that fits it, and a confirmation that says what is kept and what goes. Preview: https://chatcn.dev/preview/cancel-flow-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/cancel-flow
```

## Usage

```tsx
import { CancelFlow } from "@/components/ui/chatcn/pro/cancel-flow"

<CancelFlow
  plan="Pro"
  endsAt={subscription.periodEnd}
  reasons={[
    { id: "price", label: "It costs too much", offer: "downgrade" },
    { id: "usage", label: "I am not using it enough", offer: "pause" },
    { id: "feature", label: "It is missing something I need", ask: "What is missing?" },
  ]}
  keeps={["Every chat and file", "Projects, read only"]}
  loses={["Claude Opus 5.5", "Five times the messages"]}
  pauseMonths={[1, 2, 3]}
  downgrade={{ plan: "Plus", price: "$8 a month" }}
  onPause={(months, { reason }) => pause(months)}
  onDowngrade={() => switchPlan("plus")}
  onCancel={({ reason, detail }) => cancelAtPeriodEnd(reason, detail)}
  onResume={resume}
  onClose={close}
/>
```

Three short steps at most. The reason is optional, and some reasons ask for one line of detail. A reason can carry one offer: a pause for people who are not using it (it starts when the paid period ends and says the date it resumes), or a cheaper plan for people for whom it costs too much. Offers only appear when you configure them, and Continue to cancel sits beside the offer as a real button. The confirmation states the end date, says nothing more will be charged, and lists what is kept and what goes away side by side. The last screen can undo. Cancelling is at the end of the period; nothing is cut off early.

## Examples

### States

Example: States. No offers configured, in a narrow frame: reason, then the confirmation with the lists stacked. Preview: https://chatcn.dev/preview/cancel-flow-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `plan`, `endsAt` | `string`, `Date | string` | What is being cancelled and when the paid period ends |
| `reasons` | `CancelReason[]` | `{ id, label, offer?, ask? }` |
| `keeps`, `loses` | `string[]` | What stays, and what goes away |
| `pauseMonths` | `number[]` | Pause lengths; leave out to never offer a pause |
| `downgrade` | `{ plan, price }` | A cheaper plan to offer |
| `onPause`, `onDowngrade`, `onCancel` |  | Each gets `{ reason, detail }`; throw to show the error |
| `onResume`, `onClose` |  | Undo on the last screen; Keep my plan and Done |
| `labels` | `Partial<CancelFlowLabels>` | Every string, for translation |

## Accessibility

- Reasons and pause lengths are native radio groups.
- Each step moves focus to its heading.
- The final screen is a status message; a failure is an alert.

## Motion

Each step rises in over 200 ms. Nothing moves under reduced motion.

Source: https://chatcn.dev/docs/components/cancel-flow