Stat grid
A few numbers that carry the argument, each with one line saying what it measures.
Show code
<StatGrid stats={[
{ num: '+70pts', cap: 'NPS swing after a platform overhaul' },
{ num: '2–3wks', cap: 'typical Prototype Sprint' },
]} /> When to use it
- Two to four numbers that carry the page’s argument.
- Each can be said in a word or two and explained in a line.
Use something else when:
- There are more than four, or they need comparing: a table.
- The figure needs a sentence to make sense: write the sentence.
How it works
- Two to four numbers. More than that and none of them stand out.
- Every number is real and sourced from a case study; the caption says what it is and where it came from.
- Numbers use IBM Plex Mono with tabular figures, in the accent colour; captions are secondary text.
- Cells share 1 px dividers rather than each having its own border, so the grid reads as one object.
Counting up
A single number can count up from zero the first time it scrolls into view: <CountUp value=100 suffix="+" /> (@somnia/core/components/CountUp.astro; prefix, from and duration too). The page always holds the real number, so screen readers, print, search engines and anyone who prefers reduced motion get it straight away. Use it for one number that matters, not every figure on a page.
Accessibility
What it does for you
- Numbers are real text, never pictures of numbers.
- Each number is followed by its caption, in the order they are read.
- The number’s colour is checked against its cell, in light and dark.
- The cells reflow to one column on a narrow screen.
What you need to do
- A caption that says what the number measures and where it came from.
- Two to four numbers.
- A number that means something read alone: "+70pts", not an arrow and a colour.
Keyboard
| Key | What it does |
|---|---|
| Tab | Nothing: it is text. |
What a screen reader is told
- The number, then its caption, as plain text.
This is what the browser reports to assistive technology. What each screen reader then says varies, and has not been listened to yet.
WCAG 2.2
| Criterion | Level | How this meets it |
|---|---|---|
| 1.3.2 Meaningful Sequence | A | Number then caption, in the page’s order as on the screen. |
| 1.4.3 Contrast (Minimum) | AA | The number’s colour against its cell. |
| 1.4.10 Reflow | AA | One column on a narrow screen. |
The criteria this component has a part in. A page that uses it still has to meet the rest.
Checked
| Check | How | Result |
|---|---|---|
| Automated (axe-core) | WCAG 2.0, 2.1 and 2.2 rules at A and AA, the page in light and in dark | Passed Nothing found, light or dark |
| Narrow screen | No sideways scrolling at 320px wide (WCAG 1.4.10) | Passed No sideways scrolling |
| Keyboard and what the browser reports | Real key presses on the live example, and the role, name and state given to assistive technology | Passed 4 of 4 checks pass |
| On paper | Somnia’s print check: no overlaps, stranded headings or controls on the page | Passed No faults on 4 sheets |
| Screen reader | Listened to by a person, in VoiceOver and NVDA | Not yet Not yet checked by a person |
The 4 checks made with the keyboard, on the example at the top of this page:
- Passed Each number is text, followed by its caption
- Passed Nothing in it is a stop for the keyboard
- Passed The number and its caption each have at least 4.5:1 against the cell, in light and dark
- Passed On a narrow screen the cells stack and nothing is cut off
Run by script on against Somnia DS 1.89.0, in Chromium with axe-core 4.14.0. How these checks work, and every component's results.
Not yet checked
- How it sounds in a screen reader (VoiceOver, NVDA, TalkBack) has not been checked by a person. The roles, names and states the browser reports are checked by script; what is actually spoken is not.
- A number and its caption are two pieces of text tied only by their order. How that reads a line at a time has not been listened to.
CountUpkeeps the real number in the page while the one on screen counts. What a screen reader says during the count has not been checked.
Evidence
Where it's used
| Where | For |
|---|---|
| mediadreams.co.uk | The home page. |
| Headland Yachting | CountUp alone, on About. |
What we saw, and what changed
| When | What we saw | What changed |
|---|---|---|
| A single number on a page was still. | CountUp: it counts up once when first seen, with the real number in the page for screen readers, print and reduced motion (1.23.0). |
From building and using it on real sites, each entry taken from the changelog or the build's own notes. This is observation by the studio and its clients, not research sessions with users.
What we don't know yet
- Nothing is known about whether the numbers are read or believed.