Context Meter, animated React component
- Pro
- AI Components
- Hover
- Spring
Context Meter
A context-window token meter drawn as a 40 by 5 dot grid. Hover a category to light only its dots; the conversation keeps growing, and Compact chat drops its dots out of the grid while everything after them reflows to close the gap. Also includes Context Gauge, how full an AI model's context window is, drawn as a hundred fine ticks that rise as you add files and slide together when you compact.
Context Gauge
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| categories | ContextCategory[] | System prompt, Tools, Files, Conversation, Memory | Starting categories as { id, label, color, tokens } with tokens in thousands; read once on mount. |
| limit | number | 200 | Window size in thousands of tokens; the grid always has 200 dots. |
| growId | string | "conv" | Category that grows by 2.2K every 380ms and is cut back to 6.2K by Compact chat. |
| autoplay | boolean | false | Cycles the highlight and compacts when the window passes 90%, until someone touches the card. |
| ContextGauge.limit | number | 200000 | the model's context window, in tokens |
| ContextGauge.items | ContextItem[] | — | The files and messages filling the gauge, each as { id, kind, label, tokens }. |
| ContextGauge.keep | number | 0.16 | how much of the compacted history the summary keeps, 0 to 1 |
| ContextGauge.onChange | (items: ContextItem[]) => void | — | Called with the whole list whenever an item is added or removed. |
| ContextGauge.onCompact | (summary: ContextItem, removed: ContextItem[]) => void | — | Called after Compact, with the summary that replaced the items and the items it removed. |
| ContextGauge.enableSound | boolean | true | Soft synthesised sounds as you use it. They also follow the site-wide sound switch. |
| ContextGauge.volume | number | 0.6 | Sound level, 0 to 1. |
| ContextGauge.autoplay | boolean | false | Plays a short demo by itself until the visitor touches it. Never runs under reduced motion. |
| ContextGauge.className | string | "" | Extra classes for the outer element. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Context Meter is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Context Meter works
How full an AI model's context window is, drawn as a hundred fine ticks, each one a hundredth of the window and coloured by what fills it: system prompt, tools, files, messages, tool results. Add something and its ticks rise one after another from left to right, everything after them gliding along to make room, while the percentage rolls up. As it fills, the room that's left warms to amber and then red.
The source, the install command and the build prompt come with Pro.
Context Meter questions
How do I install Context Meter?
Run `npx shadcn@latest add @nexus-labs/context-meter`. It installs framer-motion. Context Meter is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
How do I set the categories and the window size?
Pass `categories` as `{ id, label, color, tokens }` with `tokens` in thousands, and `limit` in thousands (default 200). The grid is always 40 by 5 dots, so each dot is `limit` divided by 200. Categories are read once on mount.
What grows, and what does Compact chat do?
The category named by `growId` (default "conv") gains 2.2K every 380 ms until the window is nearly full. Compact chat drops its dots and sets it back to 6.2K. The growth runs inside the component, so no prop turns it off.
What happens when I hover or focus a category?
Each legend row is a button. Hovering or focusing it dims every dot outside that category, so keyboard users get the same highlight. The grid is a `meter` role with the token total as its value text.
Can I use my own colors, including theme variables?
Yes. `color` accepts any CSS color, including `var()`. The default System prompt category uses `--cm-ink`, which is near-black in light mode and near-white in dark mode. `autoplay` is off by default.

