Skip to content
synccn

Context Meter

New

How full the model's context window is: a ring in the composer that opens into a breakdown by source.

Smart · 200K
Fast · 128K

Installation

$ pnpm dlx shadcn@latest add @synccn/context-meter

First time in this project? Connect synccn with one command.

Usage

import { ContextMeter } from "@/components/ui/context-meter";<ContextMeter used={68400} limit={200000} breakdown={parts} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

ContextMeter

How full the model's context window is: a small ring in the composer that opens into a breakdown by source.

  • usedrequired
    number

    Tokens in the conversation now.

  • limitrequired
    number

    The model's context window, in tokens.

  • breakdown
    ContextPart[]

    What the tokens are made of: system prompt, messages, files, tools.

  • warnAt
    number

    Default 0.8

    Share of the window at which it turns amber, from 0 to 1.

  • hint
    string

    Shown in the panel when near the limit, e.g. what happens next.

  • side
    "top" | "bottom"

    Default "top"

    Opens the panel above or below the button.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/hooksuseClickOutside (closes on an outside click), useEscape (closes on Escape)
  • lib/utilscn (merges class names)

npm packages

Keyboard

  • EnterorSpaceOpen the breakdown
  • EscClose it

Accessibility

  • The button's label says how full the window is in words and numbers.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-controls, aria-expanded, aria-label
  • Closes with Escape
  • Closes when you click or tap outside