A context meter that fills turn by turn up to the 80% auto-compact line, shimmers while it compacts the conversation, then squeezes back down. The token count is an @property integer counter.
Also known as: token usage meter, context window progress, llm context usage bar.
<div class="aia-context-window-meter" role="status" aria-label="Context window usage">
<div class="aia-context-window-meter-head">
<span>Context window</span>
<span class="aia-context-window-meter-num" aria-hidden="true"></span>
</div>
<div class="aia-context-window-meter-bar" aria-hidden="true">
<i class="aia-context-window-meter-sys"></i><i class="aia-context-window-meter-tools"></i><i class="aia-context-window-meter-chat"></i>
<b class="aia-context-window-meter-mark"></b>
</div>
<div class="aia-context-window-meter-foot">
<span class="aia-context-window-meter-key" aria-hidden="true"><i></i>System <i></i>Tools <i></i>Messages</span>
<span class="aia-context-window-meter-note">
<span>Compacts at 80%</span>
<span class="aia-context-window-meter-busy">Compacting</span>
</span>
</div>
</div>@property --aia-context-window-meter-u {
syntax: "<number>";
inherits: true;
initial-value: 0.28;
}
@property --aia-context-window-meter-k {
syntax: "<integer>";
inherits: false;
initial-value: 0;
}
.aia-context-window-meter {
--c: var(--aia-color, #7c5cff);
font-size: var(--aia-size, 16px);
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.4;
position: relative;
box-sizing: border-box;
padding: 0.9em 1em;
border-radius: 0.9em;
background: color-mix(in srgb, currentColor 3%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 11%, transparent), 0 0.1em 0.2em color-mix(in srgb, currentColor 4%, transparent), 0 0.9em 2em -1.1em rgb(0 0 0 / 0.3);
--d: 9s;
--u: var(--aia-context-window-meter-u);
width: 21em;
animation: aia-context-window-meter-fill var(--d) cubic-bezier(0.5, 0, 0.2, 1) infinite;
}
.aia-context-window-meter-head {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-bottom: 0.65em;
font-size: 0.85em;
font-weight: 600;
}
.aia-context-window-meter-num {
color: color-mix(in srgb, currentColor 55%, transparent);
font: 500 0.95em ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
--aia-context-window-meter-k: calc(var(--u) * 200);
counter-reset: k var(--aia-context-window-meter-k);
}
.aia-context-window-meter-num::before { content: counter(k) "k / 200k"; }
.aia-context-window-meter-bar {
position: relative;
display: flex;
gap: 0.12em;
height: 0.6em;
padding: 0.12em;
border-radius: 999em;
background: color-mix(in srgb, currentColor 7%, transparent);
}
.aia-context-window-meter-bar i {
border-radius: 999em;
}
.aia-context-window-meter-sys {
width: 6%;
background: color-mix(in srgb, currentColor 40%, transparent);
}
.aia-context-window-meter-tools {
width: 9%;
background: color-mix(in srgb, var(--c) 45%, transparent);
}
.aia-context-window-meter-chat {
position: relative;
overflow: hidden;
width: calc((var(--u) - 0.15) * 100%);
background: var(--c);
}
.aia-context-window-meter-chat::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.75), transparent) 0 0 / 50% 100% no-repeat;
animation: aia-context-window-meter-sheen var(--d) linear infinite;
}
.aia-context-window-meter-mark {
position: absolute;
left: 80%;
top: -0.3em;
bottom: -0.3em;
width: 0.1em;
border-radius: 1px;
background: color-mix(in srgb, currentColor 45%, transparent);
}
.aia-context-window-meter-foot {
display: flex;
justify-content: space-between;
margin-top: 0.7em;
font-size: 0.72em;
color: color-mix(in srgb, currentColor 55%, transparent);
}
.aia-context-window-meter-key i {
display: inline-block;
width: 0.6em;
height: 0.6em;
margin: 0 0.25em 0 0.5em;
border-radius: 50%;
background: color-mix(in srgb, currentColor 40%, transparent);
}
.aia-context-window-meter-key i:first-child { margin-left: 0; }
.aia-context-window-meter-key i:nth-of-type(2) { background: color-mix(in srgb, var(--c) 45%, transparent); }
.aia-context-window-meter-key i:nth-of-type(3) { background: var(--c); }
.aia-context-window-meter-note {
display: grid;
text-align: right;
}
.aia-context-window-meter-note > * {
grid-area: 1 / 1;
animation: aia-context-window-meter-idle var(--d) ease infinite;
}
.aia-context-window-meter-note > .aia-context-window-meter-busy {
background: linear-gradient(90deg, var(--c) 30%, color-mix(in srgb, var(--c) 30%, #fff) 50%, var(--c) 70%) 0 0 / 300% 100%;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
font-weight: 600;
animation: aia-context-window-meter-busy var(--d) linear infinite;
}
@keyframes aia-context-window-meter-fill {
0%, 6% { --aia-context-window-meter-u: 0.28; }
10%, 17% { --aia-context-window-meter-u: 0.37; }
21%, 28% { --aia-context-window-meter-u: 0.48; }
32%, 39% { --aia-context-window-meter-u: 0.57; }
43%, 50% { --aia-context-window-meter-u: 0.69; }
54%, 76% { --aia-context-window-meter-u: 0.8; }
84%, 100% { --aia-context-window-meter-u: 0.28; }
}
@keyframes aia-context-window-meter-sheen {
0%, 58% { background-position: -100% 0; opacity: 0; }
59% { opacity: 1; }
64% { background-position: 200% 0; }
65% { background-position: -100% 0; }
70% { background-position: 200% 0; }
71% { background-position: -100% 0; }
76% { background-position: 200% 0; opacity: 1; }
77%, 100% { background-position: 200% 0; opacity: 0; }
}
@keyframes aia-context-window-meter-idle {
0%, 55%, 84%, 100% { opacity: 1; transform: none; }
58%, 81% { opacity: 0; transform: translateY(-0.5em); }
}
@keyframes aia-context-window-meter-busy {
0%, 55%, 84%, 100% { opacity: 0; background-position: 100% 0; }
58% { opacity: 1; background-position: 100% 0; }
81% { opacity: 1; background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
.aia-context-window-meter {
animation: none;
--aia-context-window-meter-u: 0.57;
}
.aia-context-window-meter-chat::after,
.aia-context-window-meter-note > * { animation: none; }
.aia-context-window-meter-note > .aia-context-window-meter-busy { animation: none; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
.aia-context-window-meter, .aia-context-window-meter *, .aia-context-window-meter::before, .aia-context-window-meter::after, .aia-context-window-meter *::before, .aia-context-window-meter *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--aia-color on the element or a parent.
Currently previewing #3b82f6.--aia-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.