Context Meter
ProNewToken and context-window usage meter with animated stacked segments, hover breakdown, warning states, and Compact action.
Installation
pnpm dlx shadcn@latest add @viewport/context-meter
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| segments* | ContextSegment[]Breakdown of tokens currently occupying the window. | — |
| limit* | numberTotal token limit of the model context window. | — |
| model | stringOptional model name shown in the header. | "200k context" |
| onCompact | () => voidCalled when the user triggers context compaction. | — |
| className | string | — |
Accessibility
- Exposes role=meter with numeric min, max, and current token count.
- Uses tabular numerals so live token counts never shift the layout.
- Segment resizing snaps immediately under reduced motion.