Usage LimitPRO
A banner for approaching and hitting message limits, with a live reset countdown, a paused composer and an upgrade CTA.
Code
2 files · 399 lines of TypeScriptPRO
Usage Limit is part of Pro
Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.
Motion notes
- The banner folds open only once usage crosses the warning ratio. From there, one card carries every state: the title swaps vertically, the icon pops, and the meter's fill moves on the layout spring while its color cross-fades from warning to danger.
- Remaining messages, the used count and the reset countdown all roll with Animated Number. Above an hour only the minutes move; under an hour the seconds tick.
- At the limit, the CTA rings out twice to draw the eye, and your composer dims, desaturates and goes inert under a “Sending is paused” hint. Upgrade nudges its arrow on hover, presses down, swaps to a spinner while busy, and the upgraded state lands with a single light sweep.
- A polite live region announces state changes but never the ticking countdown. With reduced motion, the banner fades instead of folding, the meter snaps, and the ring, sweep and spinner are removed.
Usage
Example
<UsageBanner
used={usage.messages}
limit={40}
resetAt={usage.resetsAt}
upgrading={checkout.pending}
state={plan === "pro" ? "upgraded" : undefined}
onUpgrade={startCheckout}
>
<PromptInput onSubmit={send} />
</UsageBanner>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| used | number | — | Messages (or tokens) used in the current window. |
| limit | number | — | The window's limit. |
| unit | string | "messages" | Plural unit used in copy. |
| state | "ok" | "warning" | "limit" | "upgraded" | — | Overrides the state derived from used / limit. Pass “upgraded” after a successful upgrade. |
| warnAt | number | 0.8 | Ratio at which the warning banner appears. |
| resetAt | number | — | When the window resets, as a timestamp in ms. Enables the countdown. |
| now | number | — | Current time in ms, to drive the countdown yourself. Otherwise it ticks every second after mount. |
| plan | string | "Pro" | Plan name for the CTA and the upgraded state. |
| onUpgrade | () => void | — | Called when Upgrade is pressed. |
| upgrading | boolean | false | Shows a spinner on the CTA while checkout resolves. |
| onDismiss | () => void | — | Shows a close button in the upgraded state. |
| children | ReactNode | — | Your composer. Dimmed and made inert while the limit is reached. |
| className | string | — | Classes for the wrapper. |