caliper uidocs

Context window meter

Pro

How full a model’s context window is and with what: system prompt, tools, files and conversation against the limit and the room kept for the reply, warnings at 80% and 95%, and Compact with the room it will win back. A small version sits in a composer.

Installs components/ui/context-window-meter.tsxDepends on @radix-ui/react-popover, @radix-ui/react-slot, lucide-reactMotion none in component source
pnpm dlx shadcn@latest add @caliper/context-window-meter

Context windowClaude Sonnet 5.5 · 200k

84%151k / 200k

  • System prompt3,2002%
  • Tools (14)11.8k6%
  • Files (6)64.4k32%
  • Conversation71.9k36%
  • Kept for the reply16.0k8%
  • Free32.7k16%

Over 80%. Long answers may be cut short.

Summarise
Ask anything…

When to use #

Use it for

  • Assistants that work with long conversations or many files.
  • Developer tools that show what a request sends.

Skip it when

  • Plan usage and billing; use the usage meter.

Installation #

terminal
pnpm dlx shadcn@latest add @caliper/context-window-meter

Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage #

Import it from your copy of the source. The example behind the preview comes with the source. It is built from contextUsage and ContextWindowMeter.

example.tsx
import { contextUsage, ContextWindowMeter } from "@/components/ui/context-window-meter"

The worked example comes with Pro

The 38-line example behind the preview opens here with a Pro or Team licence.

Checking your licence…

API reference #

contextUsage

component

No props of its own; it accepts the native props of its root element.

ContextWindowMeter

component
PropTypeDefaultDescription
parts *readonly ContextPart[]—
limit *number—
reservenumber0Tokens kept free for the reply.
modelstring—
onCompact((partIds: string[]) => void | Promise<void>)—
variant"compact" | "full""full"
classNamestring—

Accessibility #

It exposes status semantics, with aria-label, aria-hidden and aria-describedby kept in step with state. Changes that matter are announced through a live region.

Keyboard and focus handling comes from Radix popover: arrow keys move through items, Enter and Space select, and Escape closes and returns focus.

Motion #

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.