Billing Usage Anomaly Alert
An alert card for flagging a usage spike before it turns into a surprise bill. It shows the current period's spend next to a 30-day average, a percent-over pill, and an optional list of the resources contributing most to the spike. Two actions sit at the bottom: one to review the usage in more detail and one to dismiss the alert for a day.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-usage-anomaly-alert.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing145.tsx instead.
Usage
The file also exports billing145Demo, 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 { Billing145, billing145Demo } from "@/components/blocks/billing/billing145"; export default function Page() { return <Billing145 {...billing145Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Unusual spending detected" | Heading shown at the top of the alert. |
| severity | "warning" | "critical" | "warning" | Controls the amber-vs-red color treatment of the border, icon, and pill. |
| message | string | none | One-line explanation shown under the heading. |
| currentUsage | string | none | Formatted spend for the current period, e.g. "$1,842.00". |
| averageUsage | string | none | Formatted 30-day average spend, shown next to currentUsage. |
| percentOverAverage | string | none | Formatted percentage shown in the pill next to the title, e.g. "56%". |
| resources | AnomalyResource[] | [] | Optional list of resources driving the spike. The section is omitted entirely when the array is empty. |
| actionLabel | string | "Review usage" | Label for the primary action button. |
| actionHref | string | "#" | Destination for the primary action. |
| dismissLabel | string | "Dismiss for 24h" | Label for the secondary, lower-emphasis button. |
| dismissHref | string | "#" | Destination for the dismiss action. |
| className | string | none | Extra classes for the outer container. |
Types
interface AnomalyResource { name: string; amount: string; share: string; }
Behavior notes
- Purely presentational: currentUsage, averageUsage, and percentOverAverage are all pre-formatted strings the caller computes, the component does no math on them.
- severity swaps the border, icon, and pill colors between amber (warning) and red (critical) via a single STYLES lookup, nothing else changes.
- The resources list renders only when at least one item is passed; there's no built-in empty state or loading skeleton for it.
- Both bottom actions are next/link elements styled as buttons, not onClick handlers, so 'dismiss' has to be wired to a real route or query param on your end to actually suppress the alert.
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.