Billing Low Credit Warning
A low credit balance warning for pay-as-you-go and usage-based billing. It highlights the current balance, an optional estimated-days-remaining note, a row of quick top-up amounts, and whether auto-recharge is currently on or off. The card switches to an amber warning treatment once the balance is at or below the threshold you pass in. Built for API platforms, pay-as-you-go cloud services, and credit-based SaaS tools.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-low-credit-warning.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing70.tsx instead.
Usage
The file also exports billing70Demo, 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 { Billing70, billing70Demo } from "@/components/blocks/billing/billing70"; export default function Page() { return <Billing70 {...billing70Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Your balance is running low" | Heading shown next to the warning icon. |
| description | string | "Add credit now to avoid an interruption in service." | Supporting text under the heading. |
| currentBalance | number | none | Current balance in dollars, shown formatted to two decimal places. |
| lowBalanceThreshold | number | none | When currentBalance is at or below this, the card switches to the amber warning treatment. |
| estimatedDaysRemaining | number | none | Optional estimated days left at current usage, shown next to the balance. |
| autoRechargeEnabled | boolean | false | Whether to show the auto-recharge status row as on or off. |
| quickAmounts | QuickTopUpAmount[] | none | Preset top-up amounts, each rendered as a link to topUpHref. |
| topUpHref | string | none | Destination for every quick top-up amount button. |
| manageHref | string | none | Optional link to a full billing settings page, shown under the card. |
| className | string | none | Extra classes for the outer container. |
Types
interface QuickTopUpAmount { value: number; label?: string; }
Behavior notes
- isLow is computed on every render from currentBalance and lowBalanceThreshold. There's no internal timer or polling, pass an updated currentBalance to reflect a new balance.
- The card's border and icon color switch to amber only when currentBalance is at or below lowBalanceThreshold, otherwise it renders with the default card styling.
- Quick top-up amounts are next/link buttons pointed at a single topUpHref, they don't charge a card or update the balance themselves, wire the actual charge into whatever page topUpHref leads to.
- autoRechargeEnabled is a display-only boolean, toggling it requires re-rendering the component with a new value from your own settings state, there's no built-in switch here.
- estimatedDaysRemaining and manageHref are both optional and each independently omit their row when not provided.
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 Credit Balance
Compact credit balance card with a large total, an optional purchased-versus-promotional breakdown, a low-balance notice, and a top-up button.
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.