Count
A number in a small pill beside a name: how many there are, or how many are new.
import { Count, CountSkeleton } from '@sypnia/ui/react'
Sizes of number
One digit, two, and thousands shortened.
34871.2K38.1K
Code
import { Count } from '@sypnia/ui/react';
// From 1,000 on, the number is shortened so the pill keeps its size.
export default function Basic() {
return (
<div className="sy-row">
<Count value={3} />
<Count value={48} tone="info" />
<Count value={7} tone="fail" />
<Count value={1204} />
<Count value={38110} tone="light" />
</div>
);
} In tabs
How many orders are behind each tab.
All 1.2K
Pending 18
Failed 3
Code
import { Count, Tabs } from '@sypnia/ui/react';
export default function InTabs() {
return (
<Tabs label="Orders by state" items={[
{ id: 'all', label: <>All <Count value={1204} /></> },
{ id: 'pending', label: <>Pending <Count value={18} tone="warn" /></> },
{ id: 'failed', label: <>Failed <Count value={3} tone="fail" /></> },
]} />
);
} With a name for screen readers
label says what is counted.
Code
import { Button, Count } from '@sypnia/ui/react';
// Alone, a number says nothing to a screen reader: `label` says what is being counted.
export default function Named() {
return (
<div className="sy-row">
<Button icon="alert">Errors <Count value={7} tone="fail" label="7 errors not yet seen" /></Button>
<Button icon="users">Team <Count value={12} label="12 members" /></Button>
</div>
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
121.5K
Code
import { Count, CountSkeleton } from '@sypnia/ui/react';
// A count while it is being counted. 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-row">
<Count value={12} tone="light" /><CountSkeleton />
<Count value={1540} /><CountSkeleton />
</div>
);
} When to use it
Use it when
- A tab, a button or a menu item leads to a list and the amount helps decide: «Pending 18».
- Large numbers: from 1,000 on it shortens them (1.2K) so the pill keeps its size.
Do not use it when
- The number is the content itself: that is a Stat.
- It is zero. Show nothing instead of «0».
- It is a state in words: Badge.
For everyone
- Beside a visible name («Pending 18») it is read as part of it.
- When the number alone would be unclear,
labelgives the full sentence («7 errors not yet seen») and that is what screen readers say. - Tones add urgency by colour; the label or the name beside it must say it too.
Props
| Count | Type | Default |
|---|---|---|
valuerequired | number | |
label | string | |
tone | "light" | "info" | "ok" | "warn" | "fail" | "neutral" | neutral |