Context Window

What filled a model's context, part by part, and what was cut.

PROGet Context Window and 168 other Pro components with pro lifetime — Get Pro

Category
RAG & Evals
Access
Pro
Source
317 lines · one file
States
6 drawn
Added
12 Oct 2026

The decision inside it

Unknowns stay unknown

Without a model limit there is no "remaining" and no percentage of the window; the bar then compares the parts with each other and says so.

When to use it

Use Context Window to show what fills a model's context: system prompt, history, retrieved chunks and tool results as segments of one bar, tokens used against the limit, and what was cut.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Context Window for this.
Install it: npx shadcn@latest add @liro/context-window
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/context-window.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/context-usage.tsx
import { ContextWindow, type ContextWindowData } from "@/components/ui/context-window";

const context: ContextWindowData = {
  model: "your-model",
  maxTokens: 128_000,
  reservedForOutput: 4_000,
  segments: [
    { id: "sys", label: "System prompt", kind: "system", tokenCount: 1_200 },
    { id: "hist", label: "Conversation", kind: "history", tokenCount: 18_400 },
    { id: "docs", label: "Retrieved docs", kind: "retrieval", tokenCount: 42_000, truncated: true, truncationNote: "3 chunks dropped" },
  ],
};

export function ContextUsage() {
  return <ContextWindow context={context} warnAt={0.8} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
contextContextWindowData Yes–
onSegmentSelect(segment: ContextSegment | null) => void No–
onCopySegment(segment: ContextSegment) => void No–
showContentPreviewboolean NoShow segment text when a row is opened. Default false.
onTruncationDetails(segment: ContextSegment) => void NoAdds "Why was this cut?" to truncated segments.
summaryOnlyboolean NoThe bar and the totals only.
warnAtnumber NoWarn above this share of the window. Default 0.9.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebadgebuttonstate

States

All of them are drawn by the component. None is left for you to design.

  • Near the limit
  • Plenty of room
  • Limit unknown
  • Truncated
  • Content hidden
  • Content shown

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances