Staaarter

Billing History Chart

A billing trend chart drawn as a hand-rolled SVG line with a monthly/quarterly toggle above it. Switching periods swaps the dataset and redraws the line, while the total and a trend arrow above the chart compare the most recent point to the one before it. A visually hidden table mirrors the same data for screen readers.

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

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

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing64.tsx instead.

Usage

The file also exports billing64Demo, 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 { Billing64, billing64Demo } from "@/components/blocks/billing/billing64";

export default function Page() {
  return <Billing64 {...billing64Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Spending history"Card heading.
descriptionstringnoneOptional supporting text under the heading.
monthlyPointsHistoryPoint[]noneData points shown when the monthly toggle is active.
quarterlyPointsHistoryPoint[]noneData points shown when the quarterly toggle is active.
defaultPeriod"monthly" | "quarterly""monthly"Which dataset is active on first render.
currencySymbolstring"$"Symbol prefixed to every formatted amount.
classNamestringnoneExtra classes for the outer container.

Types

interface HistoryPoint {
  label: string;
  amount: number;
}

Behavior notes

  • Switching the monthly/quarterly toggle swaps which points array is used and redraws the SVG path and circles; there's no built-in transition between datasets.
  • The total shown above the chart is the sum of the currently active dataset's amounts, not a fixed value.
  • The trend arrow and percentage compare only the last two points of the active dataset. With fewer than two points it shows a flat (no-change) indicator.
  • The line is a plain SVG path scaled to the active dataset's own maximum value, so the vertical scale resets when switching periods rather than sharing one fixed axis.
  • Each data point renders a native SVG <title> for hover text, and a visually hidden table below the chart lists every point's label and amount for screen readers.

Frequently asked questions