Context Meter
ProHow full the model's context window is: a ring for the prompt toolbar, or a bar that shows what fills the window and warns before it is full.
Playground
Context window
74k of 200k tokens
- System 6.2k
- Files 41.8k
- Conversation 26k
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
Context window
212k of 200k tokens
- System 6.2k
- Files 118.4k
- Conversation 87.4k
Nearly full — older messages get summarised next.
Installation
Context Meter comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { ContextMeter } from "@wunderui/react"Then use it:
import { ContextMeter } from "@wunderui/react"
const parts = [
{ label: "System", tokens: 6_200 },
{ label: "Files", tokens: 41_800 },
{ label: "Conversation", tokens: 26_000 },
]
export function Window() {
return <ContextMeter variant="bar" used={74_000} limit={200_000} breakdown={parts} />
}Expected result: You see Context window and 74k of 200k tokens, a bar in three segments with free space at the end, and a legend with each part's tokens. From 80% the figures turn amber.
When to use
Use Context Meter for
- How full the context window is, as a ring in the toolbar of a prompt
- What fills the window (system, files, conversation, tools) as a bar with a legend
- A warning before the window is full, with the next step beside it
Use something else for
- Usage Meter for one limit of a plan as a row, such as tokens per day
- Progress for how far a task has come, not how full a window is
Breakdown
Each part is a bar segment and a legend entry, in the order you pass them. The empty end of the track is free space, and the parts should add up to the used total.
Context window
74k of 200k tokens
- System 6.2k
- Files 41.8k
- Conversation 26k
Context window
83k of 200k tokens
- System 6.2k
- Tools 9k
- Files 41.8k
- Conversation 26k
Context window
74k of 200k tokens
Warning threshold
The warning threshold is a share of the window between 0 and 1. From there the figures and ring turn amber and the bar shows the hint, while its segments keep their colours.
Warn at
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Content
The label names the meter. The warning is the compaction hint under the bar: say what happens next, offer the action beside it, or hide it.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
Model context
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full. Summarize the chat to keep going.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Actions and toolbar spacing
On the bar, actions puts buttons under the warning (summarise, start fresh). The ring keeps an 8 px start margin by default so it sits apart from the toolbar buttons before it.
Actions under the warning, ring in a toolbar
Context window
172k of 200k tokens
- System 6k
- Files 98k
- Conversation 68k
Nearly full — older messages get summarised next.
Keyboard interactions
The bar is not interactive. The ring is interactive only with a breakdown, when it becomes a native button that opens a tooltip.
- TaborShift+Tab
- Moves focus to the ring and away from it. Focus opens the tooltip with the breakdown.
- Esc
- Closes the tooltip. Focus stays on the ring.
Without a breakdown the ring is plain text and not a tab stop.
Behavior and motion
How the meter turns two numbers and a list of parts into a fill and a warning, and how the ring differs from the bar.
- Fill and warning
- The fill is used divided by the limit, capped at full. From the warning threshold (80% by default) the figures and the ring turn amber and the bar shows its hint.
- Over the limit
- The text is not capped: 212,000 of 200,000 reads 212k of 200k tokens, while the ring is a full circle. Treat it as a bug in your count, not a normal state.
- Segments
- Each part is a segment as wide as its share of the limit, in the order you pass them, with free space at the end. Colours cycle through four; a background class on a part overrides its colour.
- Colour at the warning
- At the warning, segments keep their colours and only the figures, ring and hint turn amber. Without a breakdown the bar is one fill that does turn amber.
- Hint
- In the bar, the warning line appears from the threshold, by default Nearly full, older messages get summarised next. Pass your own text, or null to hide it.
- Number format
- Numbers are English and short from 1,000: 98.4k, 172k, 1.25M. The figures use the short form only, so show the exact count in your own text where it matters.
- Meter semantics
- The bar is a meter from 0 to the limit, named by the label, with the summary as its value text. The ring is plain text, or with a breakdown a button named Context window: 172k of 200k tokens.
- Live updates
- Pass a new used value and the figures, segments and warning change at once. Nothing is announced automatically, so say the change in a status line next to the meter.
- Motion
- The bar does not move. The ring arc eases over the ambient duration with the entrance curve, using stroke-dasharray instead of transform, a known gap shared with Usage Meter.
- Reduced motion
- With reduced motion the arc jumps to its new length. The figures and colours stay the same.
Anatomy
The figure shows the bar when it is nearly full, so the hint appears. The ring and its tooltip are separate forms of the same component and are not numbered.
Context window
172k of 200k tokens
- System 6.2k
- Files 98.4k
- Conversation 67.4k
Nearly full — older messages get summarised next.
- 1data-slot="context-meter"
The row. It marks itself normal or warning, and a variant picks the bar (shown in the figure) or the ring.
- 2
Context window by default. In the bar it names the meter; in the ring it is part of the tooltip and the button name.
- 3
The summary, such as 172k of 200k tokens, which turns amber from the warning threshold. The ring writes 172k / 200k beside the circle instead.
- 4
An 8 px track exposed as a meter from 0 to the limit. Each part is a segment with 2 px between them, and the empty end is the free space.
- 5Optional
One entry per part, in order, with a dot in the segment colour, the label and its tokens, such as Files 98.4k. It wraps on a narrow screen.
- 6Optional
The warning line under the legend, shown in the bar from the warning threshold. It says what happens next, and the ring never shows it.
- Optional
In the ring variant: a 20 px circle that fills clockwise from the top, with the figures beside it. It turns amber at the warning threshold.
- Optional
With a breakdown, the ring and its figures become one button. Hover or focus opens a tooltip with the label, the summary and the legend.
Best practices
- Do
Pass a breakdown whose parts add up to the used count. The bar draws the parts and the header writes the total, so mismatched numbers show two different fill levels.
- Do
Order the parts by what stays and what goes: system and files first, the conversation last, free space at the end of the bar.
- Do
Rewrite the warning to say what your product does next, and put the action beside it, such as Summarize and continue.
- Do
Use the ring with a breakdown in a toolbar. It becomes a button, so keyboard and screen reader users can reach the parts.
- Don’t
Don't keep the default warning if nothing summarises. It promises that older messages get summarised next, but the meter only says it.
- Don’t
Don't count characters as tokens. Use the count your backend reports, or the estimate drifts from the real window.
- Don’t
Don't use the ring without a breakdown where people need to see what fills the window. Without one it is plain text and takes no focus.
API reference
ContextMeter is a plain component, so this table lists every prop.
The row. It marks itself normal or warning, and a variant picks the bar (shown in the figure) or the ring.
| Prop | Type | Default | Description |
|---|---|---|---|
| used required | number | — | Tokens in the window. It should equal the sum of the parts of . |
| limit required | number | — | The size of the window in tokens. 0 draws an empty meter. |
| breakdown | ContextPart[] | — | What fills the window: per part. is a Tailwind background class for the segment and its dot. In the ring the parts open in a tooltip, in the bar they are segments and a legend. |
| variant | "ring" | "bar" | "ring" | (default) is compact, for a prompt toolbar. shows the label, the summary, the segments, the legend and the hint. |
| label | string | "Context window" | The name of the meter, by default. It is the heading of the bar and part of the ring's tooltip and button name. |
| warnAt | number | 0.8 | The share of the window, from 0 to 1, where the meter turns amber. Default . |
| warning | ReactNode | "Nearly full — older messages get summarised next." | The hint under the bar from . Default hides it. The ring does not show it. |
| className | string | — | Extra classes for the meter, for example . |
| actions | ReactNode | — | only: buttons under the warning, e.g. "Summarise and continue" and "Start a new chat". |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("context-meter")The full library index for assistants is at /llms.txt.