Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Metered Usage Forecast Billing Block for React Aria

A metered bill's running spend with three forecast methods (run rate, last 7 days, last month) drawn against an editable budget line, and a sentence naming the day the chosen forecast crosses it.

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

Show customers where a metered bill is heading, inside your app, with this usage forecast for React with React Aria. A hairline frame with a plus mark on each corner holds a chart of the month's running spend: the actual line to day 18, the chosen forecast dashed to the end of the month, the other two as faint lines, and a heavy budget line across it with a diamond where the forecast reaches it. Beside it a vertical Toggle Group picks the method and prints each one's month-end figure, a Number Input sets the budget, and one sentence states the result ("At the last 7 days pace you cross $250 on day 30"). A Shine Button sets an alert at the budget, the only colored control. A side cell divided by Guides holds the controls. For data, compute and API products that bill by what runs.

FAQ

How do I feed it my own spend?

Edit SPEND, the dollars each day of the month so far cost, and MONTH for the month's length and the day the data runs through. LAST_MONTH holds what the previous month spent on the days that match the rest of this one, taken from your own invoices. The running totals, the three forecasts and the axis are all derived from those three, so adding a day to SPEND moves the whole chart.

How are the three forecasts worked out?

Run rate takes the average of every day so far and repeats it for each remaining day. Last 7 days does the same with only the most recent seven, so it follows a recent rise or fall. Last month adds what the previous month spent on the same stretch. All three add to the actual total, so they start together at the end of the solid line and fan out. None of them knows about a launch or a price change; they are straight arithmetic, and the sentence says "pace", not "will".

What does the budget do?

It sets the heavy line and the alert amount. Type a figure between $50 and $500 or use the buttons; the line moves, the crossing day is worked out again and the button reads "Alert me at" the new figure. If the actual spend has already passed it, the sentence says on which day instead. The alert is only noted on this page; in your app, send the amount to your alert rules from the same button.

Can the chart be read without seeing it?

The chart is one image with a label that gives the spend so far, each method's month-end figure and the sentence, and an sr-only table lists the same three methods with the day each crosses the budget. The method buttons are a pressed-state group and their month-end figures are part of their names. React Aria commits a typed budget on blur, Enter or an arrow key, not on every keystroke.

Does the chart flip in a right-to-left page?

No. Time runs the same way in every language, so the chart stays left to right while the labels, sentence and controls around it follow the page.

How does it look on a phone?

The chart comes first at full width, then the method list, the budget field and the sentence, and the alert button in a foot that sticks to the bottom of the screen.