Compact breakdown
A compact part-to-whole card pairing a headline total, a stacked bar, and ranked category rows.
import { CompactBreakdown } from '@uthereal/ui/compact-breakdown'Compact breakdown playground
Total revenue
Total revenue: $13,590, up 12.4%
| Category | Value | Share |
|---|---|---|
| Direct | $4,820 | 35% |
| Organic search | $3,910 | 29% |
| Referrals | $2,240 | 16% |
| Social | $1,680 | 12% |
| $940 | 7% |
Overview
A compact breakdown summarizes a total and its constituent parts inside a tight card layout. It pairs a headline total (with optional percentage delta and period switcher) with a horizontal stacked strip and a value-ranked list of category rows. Hovering a bar segment or focusing a row previews that category's value and share in the headline while emphasizing its segment and dimming the rest. A native data table exposes every supplied category.
Use a compact breakdown inside dashboards, sidebars, and summary cards where space is limited. For circular proportions with a legend, use a donut chart. For countable unit grids, use a waffle chart.
Usage
import { CompactBreakdown } from '@uthereal/ui/compact-breakdown'
export function RevenueBreakdown() {
return (
<CompactBreakdown
title="Revenue"
valueFormat={{
style: 'currency',
currency: 'USD',
maximumFractionDigits: 0,
}}
parts={[
{ id: 'direct', label: 'Direct', value: 4820 },
{ id: 'organic', label: 'Organic search', value: 3910 },
{ id: 'referrals', label: 'Referrals', value: 2240 },
]}
/>
)
}Supply nonnegative finite parts with stable unique id values. When periods contains two or more options, a segmented control switches periods via period and onPeriodChange; the host supplies updated parts and delta for the selected period.
Examples
Aggregating more than eight categories
When more than eight parts are supplied, smaller entries fold into an "Other" segment and row in the card while the accessible data table (tableToggle: true) continues to list every supplied category.
Total
Total: $8,250, down 6.4%
| Category | Value | Share |
|---|---|---|
| Americas | $2,400 | 29% |
| Europe | $1,800 | 22% |
| Asia Pacific | $1,200 | 15% |
| Middle East | $600 | 7% |
| Africa | $550 | 7% |
| Oceania | $500 | 6% |
| Caribbean | $450 | 5% |
| Central Asia | $400 | 5% |
| Other regions | $350 | 4% |
Behavior
Category rows sort descending by value, whereas stacked bar segment order and palette colors (series1–series8) stay pinned to stable category identity across period updates. Custom color values on parts override their palette slot. Empty or all-zero datasets remain readable, and the optional footer (showFooter, default true) displays footer or defaults to naming the largest category.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Breakdown" | Card and chart title |
parts | ChartPart[]Default: [] | Nonnegative parts, stable unique IDs in color order; empty is valid |
periods | Period[]Default: [] | Host-supplied period options |
defaultPeriod | string— | Initial period; current selection wins |
delta | number— | Host-supplied percentage change |
totalLabel | stringDefault: "Total" | Caption for the sum |
footer | string— | Optional supporting footer text |
showFooter | booleanDefault: true | Show footer, defaulting to the largest part |
valueFormat | NumberFormat— | Intl number formatting options |
locale | string— | Number locale; omitted inherits |
tableToggle | booleanDefault: false | Offer the accessible data table |
motionOptions | object— | Optional chart transition overrides; durations are milliseconds |
recipe | studio | softDefault: "studio" | Visual treatment; behavior is identical |
motion | none | subtle | expressiveDefault: "subtle" | Arc motion; reduced motion wins |
dir | ltr | rtl— | Reading direction; omitted inherits |
theme | CompactBreakdownTheme— | Mode, accent and typed theme tokens |
React integration
| Prop | Purpose |
|---|---|
period | Controlled selected period ID matching an entry in periods |
onPeriodChange | Fires with the selected period ID when the period switcher changes |
preset | Application defaults, overridden by explicit instance props |
tokens | CSS variables applied after the typed theme |
ref | Ref forwarded to the root <figure> |
className, style | Applied to the root <figure> |
| Native attributes | id, data-*, and remaining <figure> attributes forwarded to the root |
Keyboard & accessibility
| Focus target | Key | Interaction |
|---|---|---|
| Period switcher | ArrowLeft, Right | Switch between configured periods |
| Category rows | Tab, Shift+Tab | Move focus across ranked category buttons to preview values |
| Data table | Enter, Space | Toggle the visible data table when tableToggle is enabled |
The chart renders a <figure> named by title and linked via aria-details to a native data table containing every supplied category, value, and percentage share (including parts folded into "Other"). The visual stacked bar and animated headline digits are aria-hidden, while a polite role="status" region announces the active total, previewed category, and delta direction. Each row button carries an accessible label with its name, formatted value, and share. In RTL (dir="rtl"), layout and period controls mirror automatically.
Motion and theming
A shared animation clock interpolates the headline total, delta magnitude, row values, and stacked bar widths together on motionOptions.morph, while ranked rows reposition with layout transitions when order changes. Segment hover and focus scale the active segment vertically (scaleY: 1.5) and dim inactive segments to 40% opacity. Server-rendered markup is final. motion="none" and prefers-reduced-motion: reduce snap values, widths, and row order immediately.
theme accepts a mode, an accent, and semantic tokens across the chart palette, display typography (fontFamilyDisplay), surface tokens (surfaceRadius, surfaceSunken), and status tones (success, warning, danger). An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, CompactBreakdown is a leaf with no actions. The selected period is host state stored at /components/instance-<id>/period, initialized from defaultPeriod. The host updates parts and delta through composition updates. See Building with agents.
{
"type": "CompactBreakdown",
"props": {
"title": "Revenue by channel",
"parts": [
{ "id": "direct", "label": "Direct", "value": 4820 },
{ "id": "organic", "label": "Organic search", "value": 3910 }
]
},
"children": []
}