UI

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

Revenue by channel
Revenue by channel
Period

Total revenue

Total revenue: $13,590, up 12.4%

Revenue by channel
CategoryValueShare
Direct$4,82035%
Organic search$3,91029%
Referrals$2,24016%
Social$1,68012%
Email$9407%
Loading interactive preview…

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.

Revenue across regions
Revenue across regions

Total

Total: $8,250, down 6.4%

Revenue across regions
CategoryValueShare
Americas$2,40029%
Europe$1,80022%
Asia Pacific$1,20015%
Middle East$6007%
Africa$5507%
Oceania$5006%
Caribbean$4505%
Central Asia$4005%
Other regions$3504%

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.

ArgumentType / defaultDescription
titlestringDefault: "Breakdown"Card and chart title
partsChartPart[]Default: []Nonnegative parts, stable unique IDs in color order; empty is valid
periodsPeriod[]Default: []Host-supplied period options
defaultPeriodstring—Initial period; current selection wins
deltanumber—Host-supplied percentage change
totalLabelstringDefault: "Total"Caption for the sum
footerstring—Optional supporting footer text
showFooterbooleanDefault: trueShow footer, defaulting to the largest part
valueFormatNumberFormat—Intl number formatting options
localestring—Number locale; omitted inherits
tableTogglebooleanDefault: falseOffer the accessible data table
motionOptionsobject—Optional chart transition overrides; durations are milliseconds
recipestudio | softDefault: "studio"Visual treatment; behavior is identical
motionnone | subtle | expressiveDefault: "subtle"Arc motion; reduced motion wins
dirltr | rtl—Reading direction; omitted inherits
themeCompactBreakdownTheme—Mode, accent and typed theme tokens

React integration

PropPurpose
periodControlled selected period ID matching an entry in periods
onPeriodChangeFires with the selected period ID when the period switcher changes
presetApplication defaults, overridden by explicit instance props
tokensCSS variables applied after the typed theme
refRef forwarded to the root <figure>
className, styleApplied to the root <figure>
Native attributesid, data-*, and remaining <figure> attributes forwarded to the root

Keyboard & accessibility

Focus targetKeyInteraction
Period switcherArrowLeft, RightSwitch between configured periods
Category rowsTab, Shift+TabMove focus across ranked category buttons to preview values
Data tableEnter, SpaceToggle 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": []
}

On this page