Context Meter
Context-window usage as an LED bar split by system, conversation, files and tools, with zones and a breakdown.
New in 1.6.Built on Popover.
Context window, Argon 2
142.3k/ 200k
57.7k free
| System prompt | 3,100 tokens | 2% |
|---|---|---|
| Conversation (41 turns) | 88,500 tokens | 44% |
| Files (6 open) | 38,900 tokens | 19% |
| Tools (github, postgres) | 11,800 tokens | 6% |
| Free | 57,700 tokens | 29% |
Past 90%, the oldest turns are summarised into a short brief before the next reply.
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/context-meter.jsonUsage
import { ContextMeter } from "@/components/ui/context-meter"
<ContextMeter size="sm" limit={200_000} parts={parts} breakdown />Examples
In a composer toolbar
size="sm" is ten cells and a readout in a 32px button. breakdown opens the full panel in a popover.
Warning and critical
The compact meter takes one color by status: neon, amber from warnAt, red from criticalAt, where the last lit cell blinks. Crossing into a zone is announced once.
Sidebar
size="md" spans its container with 24 cells. A million-token window reads the same way as a 200k one.
API reference
Without breakdown the root has role="meter". With it, the root holds a button that opens the panel. Other div attributes go on the root.
| Prop | Type | Default |
|---|---|---|
parts | ContextPart[]What fills the window, in order: { label, tokens, color? }. Free space is what's left of limit. | None |
used | numberTotal tokens, when you don't have a breakdown. Ignored if parts is set. | None |
limit | numberThe window size in tokens. | None |
size | "sm"sm for a toolbar, md for a sidebar, lg for a settings panel with the table of parts. | "md" |
warnAt | numberFraction where it turns amber. | 0.8 |
criticalAt | numberFraction where it turns red and the last lit cell blinks. | 0.95 |
breakdown | booleansm and md: make the meter a button that opens the full breakdown in a popover. | false |
readout | "tokens"sm only: print 142.3k / 200k, 71%, or nothing. | "tokens" |
label | stringNames the meter and heads the panel. | "Context window" |
note | ReactNodeA line under the table, such as when older turns get summarised. | None |
format | (tokens: number) => stringReplaces the 48.2k formatting everywhere. | formatTokens |
cells | numberLED count, by size. | 10 / 24 / 40 |
color | NeonColorPalette name or hex. Parts without their own color take shades of it. | inherited |
Accessibility
- The meter reports tokens: aria-valuenow is the count used and aria-valuetext reads "71% used, 142.3k of 200k tokens", with "near the limit" or "almost full" added in the zones.
- The breakdown button's name carries the same reading, so the value isn't hidden behind a click.
- The table of parts is a real table with row headers, and exact counts for screen readers (88,500 tokens).
- Crossing into amber or red is announced once through a polite live region; the reading on first render is not.
- The first part is drawn white, as fixed overhead like a system prompt; the rest take shades of the neon color. Pass color on a part to pick your own.
- The critical blink stops under reduced motion.