Billing Credit Balance
A small card widget showing the account's current credit balance as a large total, an optional line-item breakdown by source, and a low-balance notice with a top-up button. Sized for a dashboard sidebar or an AI/usage-based billing portal rather than a full billing page.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its card, button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-credit-balance.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing3.tsx instead.
Usage
The file also exports billing3Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Billing3, billing3Demo } from "@/components/blocks/billing/billing3"; export default function Page() { return <Billing3 {...billing3Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| balance | string | none | The large total shown at the top of the card, already formatted as currency. |
| breakdown | CreditBreakdownItem[] | none | Optional line items (e.g. purchased vs. promotional) listed under the total; the list is omitted entirely when not passed or empty. |
| lowBalance | boolean | false | Shows the amber low-balance notice when true. |
| lowBalanceMessage | string | "Your balance is running low." | Text shown inside the low-balance notice. |
| topUpLabel | string | "Add credit" | Label for the footer button. |
| topUpHref | string | none | Destination for the footer button. |
| className | string | none | Extra classes for the outer card. |
Types
interface CreditBreakdownItem { label: string; amount: string; }
Behavior notes
- balance is a pre-formatted string, not a number, so currency symbol and decimal formatting are entirely the caller's responsibility.
- The breakdown list renders only when the array is passed and non-empty; there's no default line items and no total-reconciliation check against balance.
- The low-balance notice is a plain conditional block driven by the lowBalance prop, not a computed threshold. Decide the threshold logic on the server or in the parent component.
- The footer button always renders and always points at topUpHref, there's no way to hide it short of not rendering the block.
- Card width is capped at max-w-xs so it reads as a sidebar or dashboard-grid widget rather than a full-width section.
Frequently asked questions
More Billing Blocks
View all →Billing Invoice List
Invoice history table with status badges, formatted amounts, and a per-row download link, built with shadcn/ui and Tailwind CSS.
Billing Failed Payment Alert
High-contrast failed-payment alert with a message, a retry button, and an optional update-payment-method button, built with shadcn/ui and Tailwind CSS.
Billing Payment Methods
A saved payment method list for React and Next.js with brand icons, a default badge, near-expiry warnings, and remove/set-default actions per row.
Billing Add Card
A card entry form for React and Next.js with auto-formatted fields, internal brand detection, and per-field validation feedback built with shadcn/ui and Tailwind CSS.
Billing Coupon Code
An inline promo code input for React and Next.js with a simulated loading state, an applied summary showing the discount amount, and an invalid-code message.
Billing Subscription Summary
A subscription summary card with plan name, price, renewal date, and per-metric usage bars, plus manage and upgrade actions.