import "capsomer/tokens.css";
import "capsomer/usage-meter.css";
import { UsageMeter } from "capsomer/react/usage-meter";
Usage
<div class="cap-usage" data-cap="usage-meter">
<p class="cap-usage-fresh">Read <time class="cap-time" datetime="2026-09-30T16:54Z">6 minutes ago</time></p>
<ul class="cap-usage-list">
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="warn">
<span class="cap-meter-label" id="u-d1">D1 rows read</span>
<span class="cap-status" data-tone="warn">[glyph]Runs out before the reset</span>
<span class="cap-meter-value">3.7 million of 5 million today</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-d1" aria-valuemin="0" aria-valuemax="5000000" aria-valuenow="3700000"
aria-valuetext="3.7 million of 5 million rows read today, projected to run out in about 6 hours, before the reset" data-projected="5223529"><span class="cap-meter-fill"></span></span>
<p class="cap-usage-why"><strong class="cap-usage-lead">Full in about 6 hours</strong>, 1 hour before the reset. At the limit, reads fail until 00:00 UTC.</p>
</li>
</ul>
<ul class="cap-usage-legend" aria-label="Key">
<li><span class="cap-usage-key" data-key="used" aria-hidden="true"></span>Solid: used</li>
<li><span class="cap-usage-key" data-key="projected" aria-hidden="true"></span>Hatched: where the day ends at the current rate</li>
</ul>
</div>
Examples
Will run out before the reset
<div class="cap-usage" data-cap="usage-meter">
<ul class="cap-usage-list">
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="warn">
<span class="cap-meter-label" id="u-d1-read">D1 rows read</span>
<span class="cap-status" data-tone="warn"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M8 1.2 15.4 14H.6z" /><path fill="var(--surface)" d="M7.3 6h1.4v4H7.3zM7.3 11h1.4v1.4H7.3z" /></svg>Runs out before the reset</span>
<span class="cap-meter-value">3.7 million of 5 million today</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-d1-read" aria-valuemin="0" aria-valuemax="5000000" aria-valuenow="3700000" aria-valuetext="3.7 million of 5 million rows read today, projected to run out in about 6 hours, before the reset" data-projected="5223529">
<span class="cap-meter-fill"></span>
</span>
<p class="cap-usage-why"><strong class="cap-usage-lead">Full in about 6 hours</strong>, 1 hour before the reset. At the limit, reads fail until 00:00 UTC.</p>
</li>
</ul>
<ul class="cap-usage-legend" aria-label="Key">
<li><span class="cap-usage-key" data-key="used" aria-hidden="true"></span>Solid: used</li>
<li><span class="cap-usage-key" data-key="projected" aria-hidden="true"></span>Hatched: where the day ends at the current rate</li>
</ul>
<div class="cap-data"><div class="enarratio-data enarratio-visually-hidden"><table><caption class="enarratio-visually-hidden">Usage against free limits</caption><thead><tr><th scope="col">Measure</th><th scope="col">Used</th><th scope="col">Limit</th><th scope="col">Percent used</th><th scope="col">Projected at the reset</th></tr></thead><tbody><tr><th scope="row">D1 rows read</th><td>3,700,000</td><td>5,000,000</td><td>74%</td><td>5,223,529</td></tr></tbody></table></div></div>
</div>
Nearly out
<div class="cap-usage" data-cap="usage-meter">
<ul class="cap-usage-list">
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="crit">
<span class="cap-meter-label" id="u-kv">KV writes</span>
<span class="cap-status" data-tone="crit"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M5 1h6l4 4v6l-4 4H5l-4-4V5z" /><path fill="var(--surface)" d="M7.2 4h1.6v5H7.2zM7.2 10.4h1.6V12H7.2z" /></svg>Nearly out</span>
<span class="cap-meter-value">962 of 1,000 today</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-kv" aria-valuemin="0" aria-valuemax="1000" aria-valuenow="962" aria-valuetext="962 of 1,000 writes today, projected to run out in about 40 minutes, before the reset" data-projected="1358">
<span class="cap-meter-fill"></span>
</span>
<p class="cap-usage-why"><strong class="cap-usage-lead">38 writes left.</strong> Full in about 40 minutes. At the limit, the watcher cannot save its pass until 00:00 UTC.</p>
</li>
</ul>
<ul class="cap-usage-legend" aria-label="Key">
<li><span class="cap-usage-key" data-key="used" aria-hidden="true"></span>Solid: used</li>
<li><span class="cap-usage-key" data-key="projected" aria-hidden="true"></span>Hatched: where the day ends at the current rate</li>
</ul>
<div class="cap-data"><div class="enarratio-data enarratio-visually-hidden"><table><caption class="enarratio-visually-hidden">Usage against free limits</caption><thead><tr><th scope="col">Measure</th><th scope="col">Used</th><th scope="col">Limit</th><th scope="col">Percent used</th><th scope="col">Projected at the reset</th></tr></thead><tbody><tr><th scope="row">KV writes</th><td>962</td><td>1,000</td><td>96%</td><td>1,358</td></tr></tbody></table></div></div>
</div>
No projection yet
<div class="cap-usage" data-cap="usage-meter">
<ul class="cap-usage-list">
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="ok">
<span class="cap-meter-label" id="u-d1-written">D1 rows written</span>
<span class="cap-meter-value">18,200 of 100,000 today</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-d1-written" aria-valuemin="0" aria-valuemax="100000" aria-valuenow="18200" aria-valuetext="18,200 of 100,000 rows written today, no projection yet">
<span class="cap-meter-fill"></span>
</span>
<p class="cap-usage-why"><strong class="cap-usage-lead">No projection</strong>: 2 days of history, 7 needed.</p>
</li>
</ul>
<div class="cap-data"><div class="enarratio-data enarratio-visually-hidden"><table><caption class="enarratio-visually-hidden">Usage against free limits</caption><thead><tr><th scope="col">Measure</th><th scope="col">Used</th><th scope="col">Limit</th><th scope="col">Percent used</th><th scope="col">Projected at the reset</th></tr></thead><tbody><tr><th scope="row">D1 rows written</th><td>18,200</td><td>100,000</td><td>18%</td><td>no projection</td></tr></tbody></table></div></div>
</div>
Stale reading, in a panel
<section class="cap-panel" aria-labelledby="p-usage">
<header class="cap-panel-head">
<h3 id="p-usage">Usage against free limits</h3>
<span class="cap-panel-src">Cloudflare</span>
</header>
<div class="cap-panel-body">
<div class="cap-usage" data-cap="usage-meter">
<p class="cap-usage-fresh" data-stale>
<span class="cap-status" data-tone="warn"><svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M8 1.2 15.4 14H.6z" /><path fill="var(--surface)" d="M7.3 6h1.4v4H7.3zM7.3 11h1.4v1.4H7.3z" /></svg>Stale</span>
<span>Read <time class="cap-time" datetime="2026-09-30T14:00Z">3 hours ago</time>. Usage has likely grown since.</span>
</p>
<ul class="cap-usage-list">
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="ok">
<span class="cap-meter-label" id="u-stale-requests">Worker requests</span>
<span class="cap-meter-value">44,100 of 100,000 today</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-stale-requests" aria-valuemin="0" aria-valuemax="100000" aria-valuenow="44100" aria-valuetext="44,100 of 100,000 requests today, projected 76 percent by the reset, read 3 hours ago" data-projected="75600">
<span class="cap-meter-fill"></span>
</span>
<p class="cap-usage-why"><strong class="cap-usage-lead">On track</strong>: about 76% by the reset at 00:00 UTC, in 10 hours.</p>
</li>
<li class="cap-usage-item cap-meter" data-cap="meter" data-tone="ok">
<span class="cap-meter-label" id="u-stale-r2">R2 storage</span>
<span class="cap-meter-value">1.2 GB of 10 GB</span>
<span class="cap-meter-bar" role="meter" aria-labelledby="u-stale-r2" aria-valuemin="0" aria-valuemax="10" aria-valuenow="1.2" aria-valuetext="1.2 of 10 gigabytes stored, no projection yet, read 3 hours ago">
<span class="cap-meter-fill"></span>
</span>
<p class="cap-usage-why"><strong class="cap-usage-lead">No projection</strong>: 2 days of history, 7 needed. This total does not reset.</p>
</li>
</ul>
<ul class="cap-usage-legend" aria-label="Key">
<li><span class="cap-usage-key" data-key="used" aria-hidden="true"></span>Solid: used</li>
<li><span class="cap-usage-key" data-key="projected" aria-hidden="true"></span>Hatched: where the day ends at the current rate</li>
</ul>
<div class="cap-data"><div class="enarratio-data enarratio-visually-hidden"><table><caption class="enarratio-visually-hidden">Usage against free limits</caption><thead><tr><th scope="col">Measure</th><th scope="col">Used</th><th scope="col">Limit</th><th scope="col">Percent used</th><th scope="col">Projected at the reset</th></tr></thead><tbody><tr><th scope="row">Worker requests</th><td>44,100</td><td>100,000</td><td>44%</td><td>75,600</td></tr><tr><th scope="row">R2 storage</th><td>1.2</td><td>10</td><td>12%</td><td>no projection</td></tr></tbody></table></div></div>
</div>
</div>
</section>
API reference
UsageMeter
Prop
Type
Required
Does
items
UsageItem[]
Yes
now
number | Date
The time of the reading. Defaults to now.
freshness
ReactNode
"Read 6 minutes ago". With stale, the line carries a warning status word.
stale
boolean
legend
boolean
The text legend under the bars; on by default.
tableLabel
string
Names the numbers' table (Enarratio's, hidden for screen readers): "Usage against free limits".
Functions
Function
Signature
Does
duration
(span: number): string
A duration in plain words, rounded to the unit a person would say: "40 minutes", "3 hours", "2 days".
utcClock
(t: number | Date): string
"00:00 UTC". A reset is a UTC time in every provider this family uses.
The rows as a table, Enarratio's DataTable shape (the first column holds the row headers), for its dataTableBlock(): the meter is the picture, and this is its numbers as text (B30).
enhance
(root?: ParentNode): () => void
Attaches to every [data-cap="usage-meter"] under root that is not attached yet, and draws its rows' bars (each row is a [data-cap="meter"]). Returns a function that detaches them.
sizeBar
(bar: HTMLElement): void
Draws one row's bar from its aria-valuenow and aria-valuemax and its data-projected (the projected total at the reset, in the same unit; absent with no projection).
Parts and data attributes
Class
Is
.cap-usage
the root
.cap-usage-fresh
a part
.cap-usage-item
a part
.cap-usage-key
a part
.cap-usage-lead
a part
.cap-usage-legend
a part
.cap-usage-list
a part
.cap-usage-why
a part
Attribute
Values
data-key
projectedused
data-stale
present or absent
data-tone
critwarn
Accessibility
Key
Does
Tab
Passes over the meters: they are values, not controls (a screen reader reads each as a meter with its name and value text). The numbers' table takes no stop
Each bar (.cap-meter-bar) is role="meter", named by its row's name (aria-labelledby), with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext that includes the projection: "3.7 million of 5 million rows read today, projected to run out in about 6 hours, before the reset".
The why line and the legend are text, so the hatching is never the only way to read the projection.
The why line sits beside the meter, not inside its role, so a screen reader reads it as text.
Forced colors: the bar, its fill and its hatching are drawn in CanvasText on Canvas (by the meter).