Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Credit Top Up Billing Block for React

A credit wallet: the balance and what it will be after the top-up, amount chips with a custom amount, auto-recharge with a threshold and amount, a pay button with a live total and the recent top-ups.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Let customers add credit to a wallet without leaving your app, with this credit top-up section for React with Base UI. A hairline frame with a plus mark on each corner holds four bands. The first shows the balance and what it will be after the top-up, in Sliding Number digits that roll as the amount changes. The second has a Segment Group of amount chips ($10, $25, $50, $100 and Custom, which opens a Number Input in the same space) beside an auto-recharge Switch with two number inputs: the balance to recharge below and the dollars to add. The third holds the total and a Shine Button, "Pay $25", the only colored control, whose digits roll too. The fourth is a Table of recent top-ups. On a phone the third band is pinned to the bottom of the screen until you scroll to it. For AI products, APIs and any app that sells prepaid credit.

FAQ

How do I fill it from my billing provider?

WALLET at the top of the file holds the balance in credits, the card's last four digits and the credits spent a day, which gives "About 12 days at 105 a day". RATE is how many credits a dollar buys, AMOUNTS are the chips, and TOP_UPS are the rows of the table, each with its dollars, ISO date and source. Replace them with your wallet and ledger, and pass them in as props if the page fetches them.

How does the pay button charge?

It's a link and does not charge anything: point it at your checkout, and pass the amount along (amount is the dollars, added the credits). The total, the "after this top-up" balance and the button's digits all come from that one amount, so they can't disagree. Custom amounts are held between $5 and $1,000.

How does auto-recharge work?

The switch turns the two inputs on and off; while it is off they are disabled and the line under them says so. When on, the line spells out the rule ("Adds $25 whenever the balance drops below 250 credits"). The block keeps the values in its own state, so save them from your own code. The balance threshold moves in steps of 50 credits and the dollar amount in steps of $5.

What does a screen reader hear?

The section is headed by an h2, with each band's title an h3. The chips are one named group, "Top-up amount", and every number input has a name that says its unit, such as "Recharge amount, in dollars". The rolling digits are read as the plain number. The table has column headers, and on React Aria it is a grid you move through with the arrow keys.

What happens on a phone?

The balances stack, the chips wrap and the two bands of controls become one column. The total and the pay button are a bar pinned to the bottom of the screen, so the button is always in reach while you pick an amount; it joins the page's flow once you scroll to it, and from the tablet width up it is an ordinary band. The table keeps three columns, with the source under the date.

Where does the link go on each base?

The Shine Button has render set to an a element and nativeButton={false}.The chips, the switch and the number inputs are the same controls on every base.
  • Pro

    Usage Alerts Billing

    Plan and usage

    Usage alert settings: percentage thresholds as switches with number inputs, recipients as email chips, and a choice between email and a webhook, with a save that checks them.

  • Pro

    Usage Meters Billing

    Plan and usage

    Usage meters for an app's settings: one row per quota with its count, a bar that turns to a warning tone at 80% and an over-limit tone past 100%, and a plain line on what happens next.

  • Pro

    Current Plan Billing

    Plan and usage

    The account's current plan in app settings: plan, price, renewal date and card, a change-plan action, every quota's usage this period on shared hairlines, and the next invoice.

  • Pro

    Credit Packs Pricing

    Usage and credits

    One-time credit packs where the amounts lead: 500, 2,000, 10,000 and 50,000 credits at display size over growing coin stacks, each pack cheaper per credit, rows with a buy button on phones.

  • Pro

    Prepaid Credits Pricing

    Usage and credits

    A top-up picker for prepaid credits: amount chips that show the bonus each earns, a field for any other amount, and the credits you get rolling to a display-size number over a paid-and-bonus bar.

  • Pro

    Invoice History Billing

    Payment and invoices

    An account's invoices: a table filtered by status (paid, due, failed) with amounts, dates and PDF links, and a retry on the failed payment. On a phone each invoice is a card.