Billing Wallet Recharge
A recharge form for usage-based wallets and prepaid credit balances. Preset amount buttons sit alongside a custom amount input, selecting one clears the other, and the recharge button shows the exact amount that will be charged. Once an amount is chosen, a preview line shows what the balance will be after the top-up completes.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, input, label dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-wallet-recharge.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing149.tsx instead.
Usage
The file also exports billing149Demo, 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 { Billing149, billing149Demo } from "@/components/blocks/billing/billing149"; export default function Page() { return <Billing149 {...billing149Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Recharge wallet" | Heading at the top of the card. |
| description | string | none | Optional one-line note under the heading. |
| currentBalance | number | none | Current wallet balance, shown top-right and used to compute the projected new balance. |
| currencySymbol | string | "$" | Symbol used in every formatted amount. |
| presetAmounts | RechargeAmount[] | none | Quick-select amount buttons shown in a 3-column grid. |
| defaultAmountId | string | presetAmounts[0].id | Which preset is selected on first render. |
| minCustomAmount | number | 5 | Minimum accepted value for the custom amount input. |
| maxCustomAmount | number | 2000 | Maximum accepted value for the custom amount input. |
| paymentMethodLabel | string | none | Optional label shown bottom-left, e.g. "Visa •••• 4242". |
| ctaLabel | string | "Recharge" | Label on the recharge button, followed by the chosen amount. |
| className | string | none | Extra classes for the outer container. |
Types
interface RechargeAmount { id: string; amount: number; bonus?: string; }
Behavior notes
- Selecting a preset clears the custom amount input, and typing in the custom input clears the preset selection, only one source of the amount is active at a time.
- The custom amount is validated against minCustomAmount and maxCustomAmount; an inline message appears once the typed value is out of range, and the recharge button stays disabled.
- The recharge button label appends the resolved amount (preset or custom) so the exact charge is visible before clicking.
- The 'New balance after recharge' line only appears once a valid amount is resolved, it's computed locally as currentBalance plus the chosen amount and is not fetched from a server.
- Clicking the recharge button does not call any payment API, wire it to your own Stripe (or other processor) flow and update currentBalance from the real result once the charge succeeds.
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.