Compact Breakdown
The total with its change, one bar in a single hue, and ranked rows with value, share and change. Switch 7d, 30d or 90d and the numbers roll, the bar glides and the rows trade places. Long lists fold behind Show more, and an empty period keeps the card's shape.
The decision inside it
It shows rank moves, not only the new order
A row that changed places carries "↑2" or "↓1", a screen reader hears "up from #3 to #1", and the footer names the biggest climb in words.
When to use it
Use Compact Breakdown for one total split into its parts in a small card, with a 7d / 30d / 90d switch and rank moves shown (↑2). Pass the parts for each period with their previous values. For a chart over time use Breakdown Chart.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Compact Breakdown for this.
Install it: npx shadcn@latest add @layro/compact-breakdown
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/compact-breakdown.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { CompactBreakdown, type BreakdownPart } from "@/components/ui/compact-breakdown";
const usd = (v: number) => v.toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 });
export function ChannelCard({ data }: { data: Record<string, BreakdownPart[]> }) {
return <CompactBreakdown title="Revenue by channel" noun="revenue" data={data} defaultPeriod="30d" format={usd} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
title | React.ReactNode | — |
noun | string | What the total measures, used in sentences: "revenue", "orders". |
datarequired | Record<string, BreakdownPart[]> | Parts for each period, keyed by period value. |
periods | BreakdownPeriod[] | — |
period | string | — |
defaultPeriod | string | — |
onPeriodChange | (period: string) => void | — |
format | (v: number) => string | — |
goodWhen | "up" | "down" | Which direction is good news. Default "up". |
maxRows | number | Rows before "Show n more". Default 6. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themesegmented-controlStates
All of them are drawn by the component. None is left for you to design.
- 30 days
- Period switch
- Rank climb
- Long list
- Empty period
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Used in a screenAll screens
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.