CostMeter

Running cost of a run against its budget. The bar eases as spend climbs, turns amber near the cap and red past it. AI.

Open playground
$0.62of $1.20
$0.58 left, 25,420 tokens

About

CostMeter is a React component in the AI category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CostMeter } from "@ashutoshswamy/smoui" and set spent, budget, tokens among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CostMeter } from "@ashutoshswamy/smoui";

<CostMeter spent={0.62} budget={1.2} tokens={25400} />

Props 5

spent

Spend so far.

number
budget

Cap for the run.

number
tokens

Token count.

number
currency

ISO code. Defaults to USD.

string
warnAt

Share where the bar turns amber. Defaults to 0.8.

number