StatGroup
A row of numbers that are read together: the summary at the top of a page or a panel.
import { StatGroup, Stat, StatGroupSkeleton } from '@sypnia/ui/react'
A row of figures
Narrow the window: the four become two by two.
Orders today21432 more than yesterday
Sales todayUS$ 9,4808% more
Refunds31 more
Average orderUS$ 44.30No change
Code
import { Stat, StatGroup } from '@sypnia/ui/react';
// As many columns as fit; two by two on a phone.
export default function Row() {
return (
<StatGroup>
<Stat label="Orders today" value="214" delta="32 more than yesterday" trend="good" />
<Stat label="Sales today" value="US$ 9,480" delta="8% more" trend="good" />
<Stat label="Refunds" value="3" delta="1 more" trend="bad" />
<Stat label="Average order" value="US$ 44.30" delta="No change" trend="flat" />
</StatGroup>
);
} Inside a panel
The panel says what the numbers are about; the unit says of how much.
Usage this month
Requests482,110of 500,000
Storage3.1of 5 GB
Members4of 5
Code
import { Button, Panel, Stat, StatGroup } from '@sypnia/ui/react';
export default function InAPanel() {
return (
<Panel title="Usage this month" actions={<Button size="sm">See plans</Button>} footer="Resets on December 1">
<StatGroup>
<Stat label="Requests" value="482,110" unit="of 500,000" />
<Stat label="Storage" value="3.1" unit="of 5 GB" />
<Stat label="Members" value="4" unit="of 5" />
</StatGroup>
</Panel>
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
Requests1,204+12%
Errors3-2
Median time84msflat
Code
import { Stat, StatGroup, StatGroupSkeleton } from '@sypnia/ui/react';
// The numbers of a dashboard while they load. The skeleton has the same box as the real one, so nothing moves when the data arrives.
export default function Skeleton() {
return (
<div className="sy-stack">
<StatGroup>
<Stat label="Requests" value="1,204" delta="+12%" trend="good" />
<Stat label="Errors" value="3" delta="-2" trend="good" />
<Stat label="Median time" value="84" unit="ms" delta="flat" trend="flat" />
</StatGroup>
<StatGroupSkeleton items={3} />
</div>
);
} When to use it
Use it when
- Two to six figures that describe the same thing or the same period.
- At the top of a dashboard, or inside a Panel with a title that says what they are about.
Do not use it when
- The figures are unrelated: putting them in one row suggests a comparison that is not there.
- There are many: the eye stops reading after five or six. Choose, or use a table.
For everyone
- It lays out as many columns as fit; on phones always two, never a sideways scroll.
- Each Stat is read in order: name, value, change.
- It adds no role. When the group needs a name, put it in a Panel with a title.
Props
| Stat | Type | Default |
|---|---|---|
labelrequired | ReactNode | |
delta | ReactNode | |
loadingThe name stays; the number is a skeleton until it comes, as long as `value` when one is given (the last known, or a typical one), and so is how it moved when the Stat has one: pass `delta` while loading to keep its line (a typical one, or `true` for a bar). | boolean | |
trend | "flat" | "good" | "bad" | |
unit | ReactNode | |
value | ReactNode |
| StatGroupSkeleton | Type | Default |
|---|---|---|
delta | boolean | true |
items | number | 4 |