Usage meter
Credits, messages or context left: quiet when there’s plenty, clear before it runs out.
Used forAI apps with creditsSettings and billing menusComposer toolbarsAPI products
Part of AI chat components for React, the parts of a chat in the order they appear.
Install with the shadcn CLI
Registered the namespace? Then it’s shadcn add @hairline/usage-meter. Set it up
Templates
Need the whole page?
63 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
AI apps with credits
Show credits or messages left and when they reset.
Settings and billing menus
A bar in the account menu that shows how much is used.
Composer toolbars
A small ring for how full the context window is.
API products
A quota meter that nudges people toward upgrading before they hit it.
What it handles for you
Running out mid-task is the worst way to learn about a limit. This stays quiet while there is plenty and becomes clearer as the limit gets close.
Quiet when there is plenty
The numbers roll as credits are spent and the bar eases, with nothing shouting.
Amber before it runs out
Once a fifth is left (you can change that) the bar turns amber and an Upgrade link opens in.
Clear when it is out
The numbers fold away, the words become “No credits left”, and the footer reads “You’re out until Oct 12.”
A bar or a ring
Use the bar in settings and menus, or a small ring that fits a composer toolbar.
Read as words
The meter reports “1,240 of 2,000 credits left” to screen readers, not just a percentage.
Any unit
Count credits, messages, tokens or anything else, and name the meter.
Overview
Running out mid-task is the worst way to learn about a limit. The meter stays quiet while there’s plenty, with numbers that roll as they’re spent; it turns amber and opens the way to upgrade once a fifth is left; and when you’re out the numbers fold away as the words glide into "No credits left" and "Resets Oct 12" morphs into "You’re out until Oct 12." Use the bar in settings and menus, or the ring, small enough for a composer toolbar, for how full the context window is.
States
- normal
- "1,240 of 2,000 credits left" over a neutral bar, and when it resets. Spending rolls the numbers (700ms) and eases the bar.
- low
- The bar turns amber once a fifth (lowAt) is left and the Upgrade link opens in beside the reset date.
- out
- Red. The numbers fold away while "credits left" morphs into "No credits left"; the footer morphs to "You’re out until Oct 12."
- ring
- A ring that fills and a percent that rolls; amber when low, red when full.
Usage
Works with
Installs with it
With the AI SDK
Map the Vercel AI SDK’s message parts and chat status onto the component’s props.
Props
- used / limit
- number
- How much is used, out of how much.
- unit / label= "credits" / "Usage"
- string
- What’s counted, and the meter’s name.
- resetAt
- number | Date
- When it resets; shown under the bar and in the out state.
- variant= "bar"
- "bar" | "ring"
- A full-width bar, or a 16px ring with a percentage.
- lowAt= 0.2
- number
- Share left at which it turns amber.
- onUpgrade / upgradeLabel= "Upgrade"
- () => void / string
- Shown when low or out.
Accessibility and motion
- role="meter" with aria-valuetext like "1,240 of 2,000 credits left", so the number is read, not a percentage.
- Colour is never the only signal: the text changes too, and the ring has a title with the full summary.
- Numbers are mono and tabular, so they don’t jitter as they roll. The rolling text is decorative; the meter’s aria-valuetext carries the real figures.
- Installs Number roll and Text morph. With reduced motion the bar, ring and numbers change in place.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Number roll, Text morph.
Source
Registry item: /r/usage-meter.json


