Billing Revenue Analytics Mini
A condensed billing analytics card showing this month's spend, last month's spend, the running average, and a trend arrow comparing the two. A top-3 category breakdown with proportional bars sits underneath. Built for account dashboards and executive summary screens where someone needs the shape of recent spending at a glance, not a full report.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-revenue-analytics-mini.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing116.tsx instead.
Usage
The file also exports billing116Demo, 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 { Billing116, billing116Demo } from "@/components/blocks/billing/billing116"; export default function Page() { return <Billing116 {...billing116Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Spending overview" | Heading shown at the top of the card. |
| periodLabel | string | "This month" | Label above the current period's total. |
| thisMonth | number | none | Current period's total spend. |
| lastMonth | number | none | Previous period's total spend, used to compute the trend percentage. |
| average | number | none | Running average monthly spend, shown as a secondary stat. |
| currencySymbol | string | "$" | Prefix applied to every formatted amount. |
| breakdown | RevenueCategory[] | none | Spend by category. Only the first three entries are rendered. |
| className | string | none | Extra classes for the outer card. |
Types
interface RevenueCategory { label: string; amount: number; }
Behavior notes
- The trend percentage is computed as (thisMonth - lastMonth) / lastMonth * 100, rounded to one decimal place, and is 0 when lastMonth is 0.
- An increase in spend is shown in the destructive color with an up-right arrow, a decrease in an emerald color with a down-right arrow, since a rising bill is the unfavorable direction here.
- breakdown is sliced to its first three entries; pass a pre-sorted array (highest spend first) if you want the biggest categories to lead.
- Each breakdown bar's width is relative to the largest amount in the shown slice, not to thisMonth, so three similarly sized categories will show similarly sized bars.
- All amounts are formatted with two decimal places and the given currencySymbol; there's no locale-aware currency formatting beyond toLocaleString's grouping.
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.