TokenMeter

How full a context window or budget is. Segments grow on springs inside one bar, the figure rolls to each count, and the bar turns amber near the limit and red past it. AI.

Open playground
Context window76K / 128K tokens
  • System prompt3.2K
  • Conversation41.8K
  • Tool results18.6K
  • Files12.4K
52K tokens left

About

TokenMeter 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 { TokenMeter } from "@ashutoshswamy/smoui" and set limit, used, segments among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<TokenMeter
  label="Context window"
  limit={128000}
  segments={[
    { label: "System prompt", value: 3200 },
    { label: "Conversation", value: 41800 },
    { label: "Files", value: 12400 },
  ]}
/>

Props 5

limit

Context window or budget.

number
used

Tokens used. Ignored when segments are given.

number
segments

Split of the usage. Adds a legend.

{ label: string; value: number }[]
warnAt

Share of the limit where the figure turns amber.

numberdefault 0.8
label / unit

Title and unit text.

stringdefault "Context" / "tokens"