Skip to content
animorio
IT
All components

AI chat context meter

Counters, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 6.4 KBGSAP 28 KBFreeDownload the zip

The context window of an AI chat, alone on black in the premium style of product shots: a bar split into what the model is holding in mind (instructions, files, conversation). Every message that arrives makes the conversation grow on a spring and the token count rolls; near the limit the bar turns amber and Compact lights up. Pressed, a sheen of liquid metal runs across the conversation, the old messages leave and fold into a single silver summary, the bar goes short again and the summary pill appears above the chat with its tick drawing itself.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "AI chat context meter" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The AI chat context meter with messages that compact into a summary</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the context window of an AI chat: a bar split into what the model is holding (instructions, files,
         conversation); each message makes the conversation grow, near the limit the bar warns, and Compact folds
         the old messages into one short summary with a sheen of liquid metal -->
    <section class="ctx" data-ctx aria-label="Context window">
      <header class="ctx__top">
        <span class="brand">
          <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.5 12 8l5.5 2-5.5 2-2 5.5L8 12l-5.5-2L8 8Z"/></svg>
          <span>Vellum</span>
        </span>
        <span class="thread">Q4 launch plan</span>
        <span class="model">Vellum 3 · 128k</span>
      </header>

      <div class="feed" data-feed aria-live="polite">
        <div class="summary" data-summary aria-hidden="true">
          <svg class="summary__ic" viewBox="0 0 16 16"><path data-sumtick d="M4 8.4 6.8 11 12 5.4"/></svg>
          <span>Summary of <b data-sumcount>24</b> earlier messages</span>
        </div>
        <div class="msgs" data-msgs></div>
      </div>

      <div class="meter">
        <div class="meter__row">
          <span class="meter__label">Context</span>
          <span class="meter__val"><b data-used>33.5k</b> <span class="of">/ 128k tokens</span></span>
        </div>
        <div class="bar" data-bar>
          <span class="seg seg--sys" data-seg="sys"><i></i></span>
          <span class="seg seg--files" data-seg="files"><i></i></span>
          <span class="seg seg--sum" data-seg="sum"><i></i></span>
          <span class="seg seg--chat" data-seg="chat"><i></i><span class="sheen" data-sheen></span></span>
          <span class="bar__mark" aria-hidden="true"></span>
          <div class="tip" data-tip role="tooltip"><b data-tipname>Conversation</b><span data-tipval>18k</span></div>
        </div>
        <div class="keys" aria-hidden="true">
          <span><i class="k k--sys"></i>Instructions</span>
          <span><i class="k k--files"></i>Files</span>
          <span><i class="k k--chat"></i>Conversation</span>
        </div>
      </div>

      <footer class="foot">
        <p class="hint" data-hint><span data-hinttext>Plenty of room</span></p>
        <button class="compact" type="button" data-compact disabled>
          <span class="compact__in">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 5h10M5 8h6M7 11h2"/></svg>
            <span>Compact</span>
          </span>
        </button>
      </footer>
    </section>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5 18.5 12l-6 1.4L9.6 19.4Z"/></svg>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

36 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “AI chat context meter” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a black ground there is only the panel of a chat with a made-up AI, Vellum: at the top the thread name and the model with its 128k token window, in the middle the latest messages, below the context bar split into three pieces (instructions, files, conversation) with the token count. Every message comes in with a small spring and makes the conversation longer; past 80% the bar turns amber, the line below warns that old messages may be forgotten and Compact lights up with a little knock. Pressed, a white light runs across the conversation, the old messages rise and vanish, a short silver piece, the summary, is born in their place and the count drops. Hovering over the pieces of the bar lifts them a little and a tooltip says what they are and how much they weigh.

How it works

The bar in percent

Each piece is as wide as its tokens over the limit (k / LIMIT x 100%), animated by GSAP with a back.out: the bar grows on a spring and stays right at any window width.

The rolling count

An object with a number goes to the new total and at each step writes the text rounded to one decimal: no tabular figures, so with Mona Sans the zero stays clean.

The compaction

A timeline sends the light across the conversation, then removes the old messages, brings the conversation close to zero and grows the silver summary piece; the pill’s tick draws itself with stroke-dashoffset.

Values to change

NameFileDefaultWhat it changes
LIMITscript.js128The model’s context window, in thousands of tokens.
WARN_ATscript.js0.8Where on the bar the warning starts and Compact lights up.
SUMMARY_SIZEscript.js4.2How many thousand tokens the summary keeps.
STEP_TIMEscript.js0.95Seconds between messages when the pilot plays on its own.
SPRINGscript.js1.4How much the bar bounces when it grows.
SHEEN_TIMEscript.js0.9Seconds of the light running across the conversation.
HOLDscript.js3.2Seconds of pause on the result before the loop starts again.

Try them in the Playground

When to use it

In an AI chat app, a writing or coding assistant, an agent’s panel: anywhere you need to show how much room the model has left and what happens when the conversation is summarized.

On phones

The panel narrows to 92% of the width, the type follows the window with clamp and the chat height also depends on the screen height; the tooltip stays inside the bar.

With reduced motion

No springs or movement: the bar changes at once, messages and summary fade in, the light does not run and the tick is already drawn.

Pitfalls

  • The bar must be split with percentages animated by GSAP straight on the inline style: GSAP does not read percentages back from the CSS.
  • The token count does not use tabular-nums: in Mona Sans the tabular zero has a slash.
  • The tooltip is placed by measuring the piece at that moment, because widths change while the bar grows.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.4 KB; the libraries: GSAP 28 KB.

Testing

Tested on 14 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All components