Staaarter

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.

By Staaarter Team
Billing
Updated June 18, 2026
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
titlestring"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.
messagestringnoneOne-line explanation shown under the heading.
currentUsagestringnoneFormatted spend for the current period, e.g. "$1,842.00".
averageUsagestringnoneFormatted 30-day average spend, shown next to currentUsage.
percentOverAveragestringnoneFormatted percentage shown in the pill next to the title, e.g. "56%".
resourcesAnomalyResource[][]Optional list of resources driving the spike. The section is omitted entirely when the array is empty.
actionLabelstring"Review usage"Label for the primary action button.
actionHrefstring"#"Destination for the primary action.
dismissLabelstring"Dismiss for 24h"Label for the secondary, lower-emphasis button.
dismissHrefstring"#"Destination for the dismiss action.
classNamestringnoneExtra 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