Skip to Content
Kokonut UI

AI-16AIUpdated, November 16, 2026

AI Context Meter

How full the context window is, as a ring in the prompt footer that opens a breakdown by source and compacts when it fills.

Install with
motion

PROSlash Command Menu and more like it are in Kokonut UI Pro

Installation

AI Context Meter is a free, open-source React component in the Kokonut UI AI collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/ai-context-meter.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/ai-context-meter

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/ai-context-meter.tsx.

npm install motion

Usage

import AIContextMeter from "@/components/kokonutui/ai-context-meter";

export default function Example() {
  return <AIContextMeter />;
}

Props

segments
ContextSegment[]

What fills the context window, in the order to draw it. When omitted, a demo conversation grows on its own.

limit
numberDefault 200_000

The model's context window, in tokens.

compactAt
numberDefault 0.8

Share of the window at which the conversation compacts, 0 to 1.

onCompact
() => void

Shows a Compact button in the panel. The demo compacts by itself.

model
stringDefault "Claude Opus"

Shown beside the meter, like the footer of a prompt box.

defaultOpen
booleanDefault false
className
string

Extra classes for the root element.

ContextSegment

idrequired
string
labelrequired
string
tokensrequired
number
color
string

A Tailwind background class for the segment, such as bg-sky-500.

Dependencies

NeedsVersionComes from
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.