shadcn.io is not affiliated with official shadcn/ui
Prepaid Credits Pricing Block for React
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.
Installation
Overview
Let customers top up as much as they like with this prepaid credits picker, shown here for Dubline Voice, an AI dubbing service where one credit dubs one minute. A compact header says what a credit buys and carries a Credits never expire outline Badge. One panel sits under it, two bands that share a hairline and carry + marks on their corners. The top band is the choice: four amount chips ($10, $25, $50, $100) in a Segment Group, each showing the bonus it earns (no bonus, then 4%, 10% and 20%), and a field for any other amount. The bottom band is the result: the credits you get at display size, rolling to each new number with Sliding Number, with a bonus badge beside it, a bar that splits the credits you pay for from the bonus, a line that turns credits into hours of dubbing and cents a minute, and a Shine Button that names the amount, the block's only primary control. It isn't a row of packs: one amount is chosen at a time and the result is the headline. Built with Segment Group, Field, Input, Badge, Sliding Number, Shine Button and Guides, with CSS transitions only. For AI generation and transcription, API credits, wallets and any prepaid balance a customer tops up in amounts they choose.
FAQ
How do I change the amounts, the bonus and the credit price?
Edit the constants at the top of the file. CREDITS_PER_DOLLAR is how many credits one dollar buys before any bonus (10 here, so a credit costs 10 cents). AMOUNTS lists the chips. BONUS_TIERS lists the bonus rates with the lowest amount each applies from, highest first, so the chips, the custom field and the result all use the same rule. CUSTOM is the least and the most a custom top-up can be. Every number on the page, including the hours of dubbing and the cents a minute, is worked out from these.
How does the other amount field work?
Typing an amount selects it and clears the chip; choosing a chip empties the field. The amount is rounded to whole dollars and held between CUSTOM.min and CUSTOM.max, so $3 counts as $5 and $9,000 as $5,000, and the line under the panel says the limits. A custom amount earns the same bonus as the chip tier it falls in: $60 gets the 10% tier. An empty or invalid field is ignored and the chip stays selected. The field is a number input, so a phone shows a numeric keyboard.
How do I connect the button to a one-time payment?
The button is a real link: a ShineButton with render set to an a element and nativeButton={false}. Build its href from the amount, for example /checkout/top-up?amount=50, and work out the credits and the bonus again on your server: the page's numbers are for display. Add the credits to the account when your payment provider confirms the payment, never from the page.
Is the top-up picker accessible?
Yes. The chips are a radio group named "Top-up amount", and each is named by its amount and its bonus ("$50, +10% bonus"); the arrow keys move between them. The field has a visible label. The display-size credits are decorative copies of a number that a screen reader reads once as plain text, and the bar is hidden from it. When a chip is chosen or the field is left, a polite live region says what the amount buys ("$50 adds 550 credits, including 50 bonus"), so typing digits doesn't speak at every key. The chosen chip has a dark border and a ring, not only a colour.
How does it look on a phone?
The four chips become a two-by-two, the other amount field takes a full row under them, and the result stacks under the choice: the credits, the bar, the line of figures and the button. The button is within the first screen and a half of an iPhone with the default amount chosen. The credits number is one size smaller than on a laptop, so even the largest top-up fits on one line at 320 pixels.
When should I use a picker instead of fixed credit packs?
Use a picker when customers' needs vary widely and you'd rather not guess four pack sizes: they choose any amount, and the bonus tiers still reward bigger ones. Use fixed packs, such as Credit Packs, when you want each size to be a named product with its own price and a best-value tag. A picker has one primary button where packs have one per card, so it also suits a section with little room.
Related
- Pro
Credit Packs Pricing
Usage and creditsOne-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
Pay As You Go Pricing
Usage and creditsUsage pricing for a serverless platform as rate rows: each billable resource with its free allowance, its starting rate at display size and the two volume steps that lower it, with one call to action in the header.
- %%%Pro
Per Transaction Pricing
Sales and partnersPer-transaction rates for a payments processor as ruled rows, each percentage at display size with its fixed fee or cap, and a region switch and call to action in the header row.
- Pro
Volume Discount Pricing With a Descending Chart
Seats and teamsPer-seat pricing that falls across four team-size brackets, drawn as a descending bar chart beside compact rows with the saving on each bracket and a call to action per row.
- Pro
Usage Slider Pricing
CalculatorsA usage-based bill calculator for a search API: a slider over monthly search volumes sits in one short band, and a meter of what the plan covers and what is billed as overage rolls the estimated bill beside it.
- Pro
Overage Pricing
Usage and creditsOverage pricing drawn as an area chart: pick a plan and see its monthly bill against the gigabytes ingested, a flat shaded block for the allowance and a rising wedge for every extra gigabyte, beside the price and a table of allowances.