# Billing overview

Plan, next invoice, usage this period and the card it goes to, on one page, with nothing in the total left to guess.

> 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: Billing overview. A team mid period and over its Opus allowance: the next invoice shows what is fixed, what is so far and where it lands. Preview: https://chatcn.dev/preview/billing-overview-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/billing-overview
```

## Usage

```tsx
import { BillingOverview } from "@/components/ui/chatcn/pro/billing-overview"

<BillingOverview
  plan={{ name: "Team", price: "$30", per: "per seat a month", seats: { used: 12, total: 15 }, renewsAt }}
  invoice={{
    date: renewsAt,
    lines: [
      { label: "Team plan, 12 seats", amount: 360, kind: "fixed" },
      { label: "Extra usage", amount: 52.8, kind: "usage", projected: 91 },
    ],
  }}
  period={{ start, end }}
  usage={[{ label: "Opus messages", used: 2120, limit: 2000, unit: "messages", overage: "$52.80 so far" }]}
  payment={{ brand: "Visa", last4: "4242", expires: "08/28" }}
  onChangePlan={openPlans}
  onViewInvoices={openInvoices}
/>
```

The next invoice separates what is known from what is still growing. Plan lines are `fixed`; `usage` lines show the amount so far and, with `projected`, where they land at the current pace. The bar draws fixed, so far and projected (hatched) on one scale, and the headline says the total so far with the estimate under it, so the bill at the end of the month is not a surprise. Seats draw as cells, usage reuses the free `usage-meter` with the period and the day of it, and a `past-due` plan leads the page with the date the card must be fixed by. A plan that `cancels` says when it ends instead of when it renews. Amounts are formatted with `currency` and `locale`.

## Examples

### States

Example: States. A failed payment with its deadline, and a plan that will not renew. Preview: https://chatcn.dev/preview/billing-overview-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `plan` | `BillingPlan` | `{ name, price, per, seats?, renewsAt, status?, graceUntil? }` |
| `invoice` | `{ date, lines }` | Lines are `{ label, amount, kind, projected? }` |
| `period` | `{ start, end }` | The current billing period |
| `usage` | `BillingUsage[]` | `{ label, used, limit, unit?, overage? }` |
| `payment`, `billingEmail` |  | The card and where invoices go |
| `currency`, `locale`, `now` |  | Formatting and the day of the period |
| `onChangePlan`, `onManageSeats`, `onChangePayment`, `onViewInvoices` |  | Each shows its button |
| `labels` | `Partial<BillingOverviewLabels>` | Every string, for translation |

## Accessibility

- Each card is a labelled region.
- The invoice bar is an image labelled with the fixed, so far and projected amounts.
- A past due payment is an alert.

## Motion

None.

Source: https://chatcn.dev/docs/components/billing-overview