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 playgroundContext window76K / 128K tokens
- System prompt3.2K
- Conversation41.8K
- Tool results18.6K
- Files12.4K
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
npm i @ashutoshswamy/smouiUsage
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.
numberdefault0.8- label / unit
Title and unit text.
stringdefault"Context" / "tokens"
More ai components
- AgentPickerChoose which agent takes the job. Cards show purpose, tools and cost; a marker slides between them and arrow keys move.
- AgentStatusPillOne pill for what an agent is doing: ready, thinking, using a tool, waiting on you or failed. The glyph and width morph between states.
- AgentTraceA run as a waterfall. Spans nest under the step that started them, bars sit at their real start and length, parents fold away children.
- AiOrbA living orb for voice and agent states: breathes, swells with sound, turns while thinking.
- ApprovalGateAn agent asks before it runs a tool. Review the input, edit it, approve once or always, or deny; the card settles into its decision.
- AttachmentChipA file waiting to be sent. A ring fills around the tile while it uploads, a warning and a Retry button replace it on failure, and remove sits inside the chip.