Context Meter

Token usage indicator (`ContextMeter`) whose compact ring and "42k / 200k" readout expand on hover or click into a breakdown bar of system, conversation, files and tool segments in chart colors, turning warning then critical near the limit and offering an async "Compact conversation" action; drops into PromptInput's `leadingAction` slot.

Preview

Context Meter preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/context-meter
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

segments
ContextSegment[]

Usage breakdown, e.g. system / conversation / files / tools.

—
limit
number

Context window size in tokens.

—
warnAt?
number

Fraction of the window at which the meter turns to a warning. Default 0.8.

0.8
criticalAt?
number

Fraction at which it turns critical. Default 0.95.

0.95
onCompact?
(() => void | Promise<void>)

Shows a "Compact conversation" action. May return a promise.

—
compactLabel?
string
Compact conversation
open?
boolean

Controlled panel state.

—
defaultOpen?
boolean
false
onOpenChange?
((open: boolean) => void)
—
openOnHover?
boolean

Open the breakdown on hover (hover-capable pointers only). Default true.

true
side?
"bottom" | "top"
top
align?
"end" | "start"
start
title?
ReactNode
Context window
className?
string
—
contentClassName?
string
—

Updated