Billing Bandwidth Usage Chart
A bandwidth or resource-consumption card for infrastructure and API platforms on a metered plan. A large used-versus-limit figure sits above a progress bar that turns amber near the limit and red past it, with a dashed marker showing where a projected end-of-cycle total would land if usage keeps trending the same way. Below that, a small bar chart breaks the same total down by day so a spike is easy to spot.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its card dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-bandwidth-usage-chart.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing24.tsx instead.
Usage
The file also exports billing24Demo, 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 { Billing24, billing24Demo } from "@/components/blocks/billing/billing24"; export default function Page() { return <Billing24 {...billing24Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Bandwidth usage" | Card header text. |
| description | string | none | Optional line under the header. |
| unit | string | "GB" | Unit label appended to the used, limit, and projected figures. |
| used | number | none | Amount consumed so far in the current cycle. |
| limit | number | none | Plan allowance for the cycle. The progress bar's fill is used divided by limit. |
| projected | number | none | Projected total by the end of the cycle. Drawn as a dashed extension past the current usage bar, omitted if not passed or not greater than used. |
| periods | BandwidthPeriod[] | none | Per-day (or per-period) values plotted in the small bar chart underneath. |
| cycleEndLabel | string | none | Optional short label next to the header figure, e.g. "resets in 6 days". |
| className | string | none | Extra classes for the outer card. |
Types
interface BandwidthPeriod { label: string; value: number; }
Behavior notes
- Status is computed from used divided by limit: under 80% is normal (primary color), 80% to under 100% is a warning (amber), and 100% or over is critical (red), and that same status drives both the bar color and the warning message below it.
- The progress percentage is calculated in the component from used and limit, it is never passed in pre-computed, so the bar and the numeric labels can never disagree.
- The projected marker only renders when projected is both provided and greater than used, drawn as a dashed border segment extending past the solid used portion of the same bar.
- The bar chart's y-scale is set from the tallest value in periods, not from limit, so it always fills the available height regardless of how usage compares to the plan allowance.
- There's no auto-refresh or polling built in; the component renders whatever used, limit, projected, and periods values it's given on each render.
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.