AI Token Usage
A gauge showing how much of the context window a conversation has used.
- AI
- 1 file
- No extra npm packages
- Accessibility notes
pnpm dlx @dowel-ui/cli add ai-token-usageNo npm packages are needed beyond what Dowel already requires.
import { TokenUsage } from "@/components/ui/ai-token-usage";Default
Thresholds
Custom Format
Inline Count
Ring
Ring With Breakdown
Compact
Danger Threshold
<TokenUsage>
| Prop | Type | Default |
|---|---|---|
limit (required)The context window. | number | — |
used (required)Tokens used so far. | number | — |
breakdownWhat is filling the window. Listed under the bar; in the ring variant, in a popover from the gauge. | TokenUsageBreakdownItem[] | — |
dangerAtFraction past which the gauge reads as critical, before the limit itself. | number | — |
formatFormats the numbers. Defaults to the runtime locale's grouping. | (value: number) => string | — |
label | string | "Context used" |
notationNumber style when | TokenNotation | — |
variant
| "bar" | "ring" | "bar" |
warnAtFraction of the limit past which the gauge warns. | number | 0.85 |
Plus every attribute of <div>.
<TokenUsageBreakdown>
| Prop | Type | Default |
|---|---|---|
items (required) | TokenUsageBreakdownItem[] | — |
format | (value: number) => string | defaultFormat |
Plus every attribute of <dl>.
<TokenCount>
| Prop | Type | Default |
|---|---|---|
value (required) | number | — |
format | (value: number) => string | — |
label | string | "tokens" |
notationNumber style when | TokenNotation | "standard" |
Plus every attribute of <span>.
9/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — fails
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes