ContextBreakdown

Show what fills the context window, group by group: a stacked usage bar, one row per group with tokens and percent, and optional suggestions to free space. A group with items expands to its items, sorted by tokens. used defaults to the sum of the groups. Suggestions are sorted critical first, then by savings; each can carry an action button. Use variant="full" (default) on a settings or usage page and variant="compact" in a popover: compact hides item and suggestion descriptions and bar tooltips. You rarely render it directly inside a chat: pass breakdown and suggestions to ContextUsage and the ring shows this component in its details. The layout is a single column and fits a 360px widget. Related pure helpers: getGroupTokens, getBreakdownTotal, sortBreakdownItems, sortSuggestions, getTotalSavings, getGroupColor, getGroupShade.

Getting Started
$pnpm add @sinups/ai-kit @mantine/core @mantine/hooks @tabler/icons-react
Examples
Wide
Narrow
Inside ContextUsage
API reference
Prop
Type
Required
groups
ContextBreakdownGroup[]
Yes
Groups of the context, for example System, Tools, MCP tools, Agents, Memory files, Skills, Messages
total
number
Yes
Context window size in tokens
used
number
No
Tokens in the context, the sum of `groups` by default
suggestions
ContextSuggestion[]
No
Ways to free context, most severe first
variant
'compact' | 'full'
No
`compact` fits the ContextUsage popover, `full` a settings page, `full` by default
defaultExpanded
string[]
No
Ids of groups expanded on the first render
labels
Partial<ContextBreakdownLabels>
No
Overrides of the default English labels
className
string
No
Class name added to the root element
style
React.CSSProperties
No
Inline styles added to the root element