Context window mapPro
What fills a model's context window as one stacked bar and a table: system prompt, tools, history, files, the reply's reserve and what is free, with drill in.
On this page
Installation
Usage
import { ContextWindowMap } from "@/components/ui/chatcn/pro/context-window-map"
<ContextWindowMap
limit={200_000}
model="Claude Sonnet 5.5"
categories={categories}
reservedOutput={8_192}
compactAt={0.9}
onCompact={compact}
/>Each category lists the items it is made of: tool schemas, turns, files. Open a row to see them largest first, in steps of the category's color, so the one tool result that ate 28 000 tokens stands out. The free context-meter is the small ring for a toolbar; this is the full breakdown behind it.
Past warnAt the map turns amber and quotes what compaction would free; past the limit it turns red and says the request will fail. compactAt draws the point where your app compacts on its own.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
limit | number | Window size in tokens |
categories | ContextMapCategory[] | { key, label, description?, tokens?, items?: { id, label, tokens, detail? }[] } |
reservedOutput | number | Tokens held for the reply |
warnAt, compactAt | number | Shares of the window. Warn default 0.8 |
compactSaves, onCompact | number, () => void | Quote the saving and add Compact |
open, defaultOpen | string | null | The category drilled into |
loading | boolean | Counting is still running |
Keyboard
| Key | Action |
|---|---|
Enter on a row | Show what the category is made of |
Esc | Back to all context |
Accessibility
- Rows with items are buttons; focus moves to Back on drill in and returns to the row after.
- The bar is an image with its totals as its name; the table carries every number in text.
Motion
Drilling in crossfades the bar and table in 150 ms when opened by pointer; keyboard and reduced motion swap them instantly.