Skip to content
Sign upPro
BillingUsage forecastMenu

Usage forecast (Pro)

ProIncluded in $99

Not how much was used, but when it runs out: the recent pace carried forward, said as a date with its likely range, on a chart you can read day by day.

ProCredits for the month with the pace picking up after a launch: the headline is the day they run out.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/usage-forecast

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { UsageForecast } from "@/components/ui/chatcn/pro/usage-forecast"

<UsageForecast
  daily={creditsPerDay}
  limit={10_000}
  periodStart={period.start}
  periodEnd={period.end}
  action={<Button size="sm" variant="outline">Top up</Button>}
/>

The pace is the average of the last window days (7 by default), carried forward to the end of the period. If that crosses the limit first, the headline is the date it does, in amber, and the chart marks the point; if not, the headline says how much of the plan will be used. The chart shows use so far as a solid line, the projection dashed and the limit as a rule. With fewer than three days of data it says it is too early rather than guessing. daysLeftAtPace gives the same pace as a number for banners. Under the line, each day's use is a bar and the days the pace is read from are a shade darker, so a sudden jump explains itself. The projection sits inside a shaded range from your slower to your busier recent days, and the line under the headline turns that into dates. Once the limit is crossed the chart marks the point in red. Move along the chart, or focus it and use the arrow keys, Home and End, to read any day, past or projected; beyond the run out the reading stops at the limit.

Examples

States

ProOn track for the period, used up before the reset, and too early to forecast.

Props

PropTypeNotes
dailynumber[]Use per day this period, oldest first
limit, unitnumber, stringDefault unit credits
periodStart, periodEndDate | string
windownumberDays the pace is read from. Default 7
actionReactNodeTop up, change plan
locale, labelsFormatting and every string

Accessibility

  • The chart is a slider over the days of the period, labelled with the headline and the usage; each step announces the day and its value, marked projected when it is.
  • Arrow keys follow the reading direction, so in right to left layouts the left arrow moves forward.
  • Amber and red always come with the sentence that explains them.

Motion

None. The forecast is a reading, not an animation.