# Trial countdown

Days left in a trial and exactly what happens at the end, in plain words: a downgrade or a charge, when, and how much. As a card, a header chip, or the whole trial as a row of days.

> 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: Trial countdown. Halfway through a two week trial, with what happens at the end said plainly. Preview: https://chatcn.dev/preview/trial-countdown-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/trial-countdown
```

## Usage

```tsx
import { TrialCountdown } from "@/components/ui/chatcn/pro/trial-countdown"

<TrialCountdown
  plan="Team"
  startedAt={trial.start}
  endsAt={trial.end}
  after={{ kind: "downgrade", to: "Free" }}
  onUpgrade={openCheckout}
/>

<TrialCountdown variant="chip" {...trial} onUpgrade={openCheckout} />

<TrialTimeline {...trial} reminderDaysBefore={2} />
```

The days left are the headline, amber in the last three. Under it, one sentence says what happens at the end: the plan drops to free and nothing is charged, or the card is charged a stated price on a stated day, with how to avoid it. Once the trial is over the sentence switches to the past tense. No countdown timers or fake urgency; honest renewal copy is what makes the upgrade button credible. `variant="bar"` is a one line strip for the top of an app, and `variant="chip"` a small pill for a header with a ring of the time left that opens checkout. `TrialTimeline` lays the whole trial out as a row of days: used days fill in, a Today marker glides along, the reminder and the last day carry their icons, and under it the three moments in order, today, the reminder email and the end, so people know you will warn them before anything changes.

## Examples

### States

Example: States. A trial that charges with the price, two days left, ended, and the one line bar. Preview: https://chatcn.dev/preview/trial-countdown-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `plan` | `string` |  |
| `startedAt`, `endsAt` | `Date | string` |  |
| `after` | `{ kind: "downgrade"; to } | { kind: "charge"; price }` | What happens at the end |
| `onUpgrade`, `onManage` | `() => void` |  |
| `variant` | `"card" | "bar" | "chip"` |  |
| `now`, `locale`, `labels` |  | A fixed clock, formatting and every string |
| `reminderDaysBefore` | `number | false` | Timeline only. When the reminder goes out. Default 2 |

## Accessibility

- A status region, so a screen reader hears the days left on arrival.
- The progress bar is decorative; the days and the end are text.
- The chip button is named by the whole headline plus Upgrade now; without `onUpgrade` the headline is read from hidden text.
- The timeline's day strip is one image labelled with the days left; every moment under it is text, and the amber last days also say how many are left.

## Motion

Timeline only: a newly used day fills upward and the Today marker glides to it, 300 ms with the ease out curve, both transforms. Nothing moves with reduced motion.

Source: https://chatcn.dev/docs/components/trial-countdown