Low credit banner (Pro)
ProIncluded in $99A warning before credits run out, in days at the real pace, with the way out right beside it, or one quiet line above the composer.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { LowCreditBanner } from "@/components/ui/chatcn/pro/low-credit-banner"
<LowCreditBanner
remaining={balance}
total={plan.credits}
daysLeft={daysLeftAtPace(balance, creditsPerDay)}
onTopUp={openTopUp}
onAutoTopUp={openAutoTopUp}
onDismiss={snooze}
/>
<LowCreditBanner variant="inline" remaining={balance} total={plan.credits} daysLeft={days} onTopUp={openTopUp} />Days at the pace you actually use credits mean more than a raw count, so that is the headline; the count sits under it and a thin bar shows what is left of a full balance. Amber while there is time, red once replies stop, and the red state cannot be dismissed. Top up is always there; turning on automatic top ups is offered beside it when you pass onAutoTopUp. The inline variant is a single line for above a composer: gray with no icon while there is time, amber with an icon below warnBelow days, red once replies stop, so it can stay on screen all the time without nagging.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
remaining, total | number | Balance and a full balance, for the bar |
daysLeft | number | At the recent pace. See daysLeftAtPace |
unit | string | Default credits |
onTopUp, onAutoTopUp, onDismiss | () => void | Each shows its button |
variant | "banner" | "inline" | Default banner |
warnBelow | number | Inline only. Days below which it turns amber. Default 3 |
locale, labels | Formatting and every string |
Accessibility
- A status while there is time, an alert once replies are paused.
- The inline line truncates instead of wrapping and drops its bar on a phone; the sentence always stays.
- Every color comes with an icon and the sentence that says what it means.
Motion
The inline bar eases to the new balance in 300 ms; nothing moves with reduced motion.